風(fēng)人園

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

          jBPM--Node Type

          Nodetype task-node

          A task node represents one or more tasks that are to be performed by humans. So when execution arrives in a task node, task instances will be created in the task lists of the workflow participants. After that, the node will behave as a wait state. So when the users perform their task, the task completion will trigger the resuming of the execution. In other words, that leads to a new signal being called on the token.
          任務(wù)節(jié)點:一個或多個可以人為執(zhí)行的任務(wù)。所以當(dāng)執(zhí)行到任務(wù)節(jié)點,任務(wù)實例將由工作流參與者的任務(wù)列表創(chuàng)建。之后,這個節(jié)點會表現(xiàn)為等待狀態(tài)。當(dāng)用戶執(zhí)行他們的任務(wù),任務(wù)完成將會觸發(fā)執(zhí)行繼續(xù)。還句話說,在token上會調(diào)用一個新的signal

          Nodetype state

          A state is a bare-bones wait state. The difference with a task node is that no task instances will be created in any task list. This can be usefull if the process should wait for an external system. E.g. upon entry of the node (via an action on the node-enter event), a message could be sent to the external system. After that, the process will go into a wait state. When the external system send a response message, this can lead to a token.signal(), which triggers resuming of the process execution.

          Nodetype decision

          Actually there are 2 ways to model a decision. The distinction between the two is based on *who* is making the decision. Should the decision made by the process (read: specified in the process definition). Or should an external entity provide the result of the decision.

          When the decision is to be taken by the process, a decision node should be used. There are basically 2 ways to specify the decision criteria. Simplest is by adding condition elements on the transitions. Conditions are beanshell script expressions that return a boolean. At runtime the decision node will loop over its leaving transitions (in the order as specified in the xml), and evaluate each condition. The first transition for which the conditions resolves to 'true' will be taken. Alternatively, an implementation of the DecisionHandler can be specified. Then the decision is calculated in a java class and the selected leaving transition is returned by the decide-method of the DecisionHandler implementation.

          When the decision is taken by an external party (meaning: not part of the process definition), you should use multiple transitions leaving a state or wait state node. Then the leaving transition can be provided in the external trigger that resumes execution after the wait state is finished. E.g. Token.signal(String transitionName) and TaskInstance.end(String transitionName).

          Nodetype fork

          A fork splits one path of execution into multiple concurrent paths of execution. The default fork behaviour is to create a child token for each transition that leaves the fork, creating a parent-child relation between the token that arrives in the fork.

          Nodetype join

          The default join assumes that all tokens that arrive in the join are children of the same parent. This situation is created when using the fork as mentioned above and when all tokens created by a fork arrive in the same join. A join will end every token that enters the join. Then the join will examine the parent-child relation of the token that enters the join. When all sibling tokens have arrived in the join, the parent token will be propagated over the (unique!) leaving transition. When there are still sibling tokens active, the join will behave as a wait state.

          Nodetype node

          The type node serves the situation where you want to write your own code in a node. The nodetype node expects one subelement action. The action is executed when the execution arrives in the node. The code you write in the actionhandler can do anything you want but it is also responsible for propagating the execution.

          This node can be used if you want to use a JavaAPI to implement some functional logic that is important for the business analyst. By using a node, the node is visible in the graphical representation of the process. For comparison, actions --covered next-- will allow you to add code that is invisible in the graphical representation of the process, in case that logic is not important for the business analyst.

          posted @ 2007-01-25 09:32 風(fēng)人園 閱讀(725) | 評論 (0)編輯 收藏

          jBPM之名詞解釋

          JbpmConfiguration:configuration of one jBPM instance.
          JbpmContext:is used to surround persistent operations to processes.
          ProcessDefinition
          ProcessInstance:is one execution of a ProcessDefinition. To create a new process execution of a process definition, just use the ProcessInstance(ProcessDefinition).
          ContextInstance:maintains all the key-variable pairs for a process instance
          TaskMgmtSession:
          ?????????????????????????????????
          findTaskInstances(java.lang.String?actorId)?
          ??????????????????????????????????get the tasllist for a given actor.(根據(jù)角色得到此角色的任務(wù)列表)
          ?????????????????????????????????loadTaskInstance(long?taskInstanceId)?
          ??????????????????????????????????get the task instance for a given task instance-id.(根據(jù)實例ID獲得任務(wù)實例)
          TaskInstance:???
          ?????????????????????????????????
          end() marks this task as done.
          ?????????????????????????????????end(java.lang.String?transitionName)?
          ??????????????????????????????????marks this task as done and specifies the name of a transition leaving the task-node for the case that the completion of this task instances triggers a signal on the token.

          posted @ 2007-01-19 12:47 風(fēng)人園 閱讀(611) | 評論 (1)編輯 收藏

          jBPM之Custom node behaviour

          在流程中會涉及到很多的分支結(jié)構(gòu),下面就用代碼說明
          public?class?AmountUpdate?implements?ActionHandler?{
          ??
          public?void?execute(ExecutionContext?ctx)?throws?Exception?{
          ????
          //?business?logic
          ????Float?erpAmount?=?get?amount?from?erp-system;
          ????Float?processAmount?
          =?(Float)?ctx.getContextInstance().getVariable("amount");
          ????
          float?result?=?erpAmount.floatValue()?+?processAmount.floatValue();
          ????update?erp
          -system?with?the?result;
          ????
          ????
          //?graph?execution?propagation
          ????if?(result?>?5000)?{
          ??????ctx.leaveNode(ctx,?
          "big?amounts");
          ????}
          ?else?{
          ??????ctx.leaveNode(ctx,?
          "small?amounts");
          ????}

          ??}

          }
          leaveNode(java.lang.String?transitionName)
          ??????????leave this node over the given transition.
          通過ctx的 leaveNode方法,來確定下一個node,這樣就可以通過代碼動態(tài)控制流程。

          posted @ 2007-01-18 14:18 風(fēng)人園 閱讀(522) | 評論 (0)編輯 收藏

          jBPM之swimlane

          ?

          swimlane一般是為了task準(zhǔn)備的,任務(wù)總是要分配到某個人頭上的。如果在流程定義文件中任務(wù)沒有指定對應(yīng)的泳道如:,那么就需要在程序代碼中分配相關(guān)的處理人taskInstance.setActorId("jeffen")。如果程序都是這樣來搞那其實是很麻煩的,而且分配代碼分散到各個地方,很容易出錯。于是引進了泳道,我們可以在流程定義文件中統(tǒng)一指定swimlane和處理人的關(guān)系、task和swimlane的關(guān)系,只需要維護這一個文件就好了,(有點像struts的配置文件)如下:

          < swimlane?name = " banker " >
          ????????
          < assignment?expression = " user(jeffen) " />
          </ swimlane >
          ......

          < task?name = " bank " ??swimlane = " banker " >

          這樣就將任務(wù)實例和處理人松耦合了,對于多任務(wù)對應(yīng)相同的處理人,這種方式的好處顯而易見。

          當(dāng)然還可以在程序中動態(tài)指定處理人,如上taskInstance.setActorId("jeffen"),也可以通過泳道實例swimlaneInstance.setActorId("jeffen")指定。

          posted @ 2007-01-18 11:56 風(fēng)人園 閱讀(2406) | 評論 (2)編輯 收藏

          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 @ 2007-01-18 11:39 風(fēng)人園 閱讀(1822) | 評論 (0)編輯 收藏

          jBPM之hello world

          參考
          http://www.aygfsteel.com/chengang/archive/2006/07/13/57986.html

          下面是根據(jù)官方開發(fā)向?qū)Ъ白约旱慕?jīng)驗寫的

          開發(fā)向?qū)咸峁┑膆elloworld例子,這個流程是單向的,沒有任何的分支,且沒有自定義actionHandler,使用的是默認(rèn)的handler
          public void testHelloWorldProcess() {
            // This method shows a process definition and one execution// of the process definition.  The process definition has // 3 nodes: an unnamed start-state, a state 's' and an // end-state named 'end'.// The next line parses a piece of xml text into a// ProcessDefinition.  A ProcessDefinition is the formal // description of a process represented as a java object.
            ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
              "<process-definition>" +
              "  <start-state>" +
              "    <transition to='s' />" +
              "  </start-state>" +
              "  <state name='s'>" +
              "    <transition to='end' />" +
              "  </state>" +
              "  <end-state name='end' />" +
              "</process-definition>"
            );
            
            // The next line creates one execution of the process definition.// After construction, the process execution has one main path// of execution (=the root token) that is positioned in the// start-state.
            ProcessInstance processInstance = 
                new ProcessInstance(processDefinition);
            
            // After construction, the process execution has one main path// of execution (=the root token).
            Token token = processInstance.getRootToken();
            
            // Also after construction, the main path of execution is positioned// in the start-state of the process definition.
            assertSame(processDefinition.getStartState(), token.getNode());
            
            // Let's start the process execution, leaving the start-state // over its default transition.
            token.signal();
            // The signal method will block until the process execution // enters a wait state.// The process execution will have entered the first wait state// in state 's'. So the main path of execution is now // positioned in state 's'
            assertSame(processDefinition.getNode("s"), token.getNode());
          
            // Let's send another signal.  This will resume execution by // leaving the state 's' over its default transition.
            token.signal();
            // Now the signal method returned because the process instance // has arrived in the end-state.
            
            assertSame(processDefinition.getNode("end"), token.getNode());
          }

          更詳細(xì)的例子可以看參考,里面有很詳細(xì)的操作說明。




          下面是根據(jù)參考例子測試時出現(xiàn)的一些問題及說明。
          一、關(guān)于數(shù)據(jù)庫,首先要修改數(shù)據(jù)庫連接,然后創(chuàng)建數(shù)據(jù)庫,里面的表格jBPM提供相應(yīng)的API去創(chuàng)建。
          public?void?testDeployProcessDefinition()?throws?FileNotFoundException?{?
          ????????
          //?從?jbpm.cfg.xml?取得?jbpm?的配置?
          ????????JbpmConfiguration?config?=?JbpmConfiguration.getInstance();
          ????????config.dropSchema();//刪除數(shù)據(jù)表結(jié)構(gòu)
          ????????config.createSchema();//創(chuàng)建數(shù)據(jù)表結(jié)構(gòu)
          ????????
          //?創(chuàng)建一個?jbpm?容器?
          ????????JbpmContext?jbpmContext?=?config.createJbpmContext();?
          ????????
          //?由?processdefinition.xml?生成相對應(yīng)的流程定義類?ProcessDefinition?
          ????????InputStream?is?=?new?FileInputStream("processes/simple/processdefinition.xml");?
          ????????ProcessDefinition?processDefinition?
          =?ProcessDefinition.parseXmlInputStream(is);?
          ????????
          ????????
          //?利用容器的方法將流程定義數(shù)據(jù)部署到數(shù)據(jù)庫上?
          ????????jbpmContext.deployProcessDefinition(processDefinition);?
          ????????
          //?關(guān)閉?jbpmContext?
          ????????jbpmContext.close();?
          ????}

          這個是根據(jù)流程配置文件最后生成的數(shù)據(jù)庫信息的測試方法,剛開始我還有一個疑問,數(shù)據(jù)庫和數(shù)據(jù)表是系統(tǒng)自動創(chuàng)建還
          是要手動創(chuàng)建,數(shù)據(jù)庫是要手動創(chuàng)建的,數(shù)據(jù)表可以自動創(chuàng)建的



          posted @ 2007-01-18 10:55 風(fēng)人園 閱讀(1014) | 評論 (0)編輯 收藏

          Struts 2.0 起步

          參考 http://www.aygfsteel.com/max/category/16130.html

          1、添加struts2的jar包,struts2-core-2.x.x.jar, struts2-api-2.x.x.jar (struts2-all-2.x.x.jar即可,其他的struts2的插件包已經(jīng)包含在里面)。
             如添加其他的插件包,可能會出現(xiàn)文件重復(fù),具體可以看異常信息。
             或者不要加all包,而使用插件包,可以減小包的大小。
          2、修改web.xml

           1 <? xml version="1.0" encoding="UTF-8" ?>
           2 < web-app  version ="2.4"  
           3  xmlns ="http://java.sun.com/xml/ns/j2ee"  
           4  xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"  
           5  xsi:schemaLocation ="http://java.sun.com/xml/ns/j2ee 
           6  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
           7   < display-name > Struts2 Hello World! </ display-name >   
           8
           9     < filter >
          10          < filter-name > Struts2 </ filter-name >
          11          < filter-class >
          12             org.apache.struts2.dispatcher.FilterDispatcher
          13          </ filter-class >
          14      </ filter >
          15      < filter-mapping >   
          16          < filter-name > Struts2 </ filter-name >   
          17          < url-pattern > /* </ url-pattern >   
          18      </ filter-mapping >   
          19 </ web-app >
          20


          3、在classpath下添加struts.properties文件,內(nèi)容如下
          struts.devMode = true
          struts.enable.DynamicMethodInvocation = false

          4、在classpath下添加struts.xml,這個是對應(yīng)struts1.x里面的struts-config.xml

           1 <! DOCTYPE struts PUBLIC
           2         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
           3         "http://struts.apache.org/dtds/struts-2.0.dtd" >
           4 < struts >
           5      < package  name ="example"  extends ="struts-default" >
           6          < action  name ="hello"  class ="com.ivo.struts2.HelloWorld"  method ="aliasAction" >
           7              < result > /hello.jsp </ result >
           8          </ action >
           9          < action  name ="Login"  class ="com.ivo.struts2.Login" >
          10        < result > /hello.jsp </ result >
          11    </ action >
          12    < action  name ="LoginX"  class ="com.ivo.struts2.LoginX" >
          13        < result > /hello.jsp </ result >
          14    </ action >
          15      </ package >
          16 </ struts >


          注意,struts2的兩個相關(guān)文件需要放在classpath下

          posted @ 2006-12-29 10:09 風(fēng)人園 閱讀(538) | 評論 (0)編輯 收藏

          Rome使用入門

          Rome的兩種使用方法
          所需jar包的下載 here,在這里可以找到與rome相關(guān)的所有文件

          1、只使用rome
          ???
          package com.ivo.rss;

          import java.io.IOException;
          import java.net.URL;
          import java.util.Iterator;

          import com.sun.syndication.feed.synd.SyndEntry;
          import com.sun.syndication.feed.synd.SyndFeed;
          import com.sun.syndication.io.FeedException;
          import com.sun.syndication.io.SyndFeedInput;
          import com.sun.syndication.io.XmlReader;
          public class Feed {
          ??? public static void main(String[] args) throws Exception {

          ???????
          ??????? SyndFeedInput input = new SyndFeedInput();
          ??????? //System.out.println(warmedFeed);
          ??????? SyndFeed feed = input.build(new XmlReader(new URL("
          http://rss.news.yahoo.com/rss/topstories ")));

          ??????? // Iterate through feed items, adding a footer each item
          ??????? Iterator entryIter = feed.getEntries().iterator();
          ??????? while (entryIter.hasNext()) {
          ??????????? SyndEntry entry = (SyndEntry) entryIter.next();
          ??????????? System.out.println(entry.getPublishedDate());
          ??????????? System.out.println(entry.getTitle());
          ??????????? //System.out.println(entry.getDescription());
          ??????????? //System.out.println(entry.getAuthor());
          ??????????? System.out.println(entry.getLink());
          ???????????
          ??????? }
          ??? }

          }

          2、使用rome+rome fetcher

          package com.ivo.rss;

          import java.net.URL;
          import java.util.List;

          import com.sun.syndication.feed.synd.SyndContent;
          import com.sun.syndication.feed.synd.SyndEntry;
          import com.sun.syndication.feed.synd.SyndFeed;
          import com.sun.syndication.fetcher.FeedFetcher;
          import com.sun.syndication.fetcher.impl.FeedFetcherCache;
          import com.sun.syndication.fetcher.impl.HashMapFeedInfoCache;
          import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher;

          public class RssReader {

          ??? public static void main(String[] args) throws Exception {
          ??????? FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
          ??????? FeedFetcher feedFetcher = new HttpURLFeedFetcher(feedInfoCache);
          ??????? SyndFeed feed = feedFetcher.retrieveFeed(new URL(
          ??????????????? "
          http://feeds.feedburner.com/jscud "));
          ??????? List entryList = feed.getEntries();
          ??????? for (int i = 0; i < entryList.size(); i++) {
          ??????????? SyndEntry entry = (SyndEntry) entryList.get(i);
          ??????????? System.out.println("Published Date: "+entry.getPublishedDate());
          ??????????? System.out.println("Title: "+entry.getTitle());
          ??????????? System.out.println("Link: "+entry.getLink());
          ??????????? //System.out.println(entry.getDescription());
          ??????????? SyndContent sc = entry.getDescription();
          ??????????? System.out.println("Description: "+sc.getValue());
          ??????????? System.out.println("------------------------------");
          ??????? }
          ??? }
          }

          上面是使用了緩存的,也就是說更新才讀取,如果每次都讀取,則修改對應(yīng)行為:

          FeedFetcher feedFetcher = new HttpURLFeedFetcher();

          posted @ 2006-07-07 14:20 風(fēng)人園 閱讀(1331) | 評論 (3)編輯 收藏

          僅列出標(biāo)題
          共10頁: First 上一頁 2 3 4 5 6 7 8 9 10 
          主站蜘蛛池模板: 韶关市| 驻马店市| 丰顺县| 西华县| 宁陕县| 宝坻区| 淳化县| 江北区| 南京市| 大石桥市| 宣汉县| 镇赉县| 广德县| 班戈县| 黄骅市| 长丰县| 平舆县| 浦江县| 江门市| 邓州市| 晋江市| 桓台县| 马鞍山市| 绍兴市| 塔河县| 宣化县| 阜新| 凭祥市| 淄博市| 双辽市| 阳城县| 历史| 德保县| 永新县| 长阳| 西乌珠穆沁旗| 卢湾区| 新邵县| 临漳县| 鹰潭市| 泾阳县|