• 2005年09月15日

    Shark里面如何使用自定义数据类型

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    http://fireshort.blogbus.com/logs/1437764.html

    gramani总结得很好。

    Step 1. Write a trivial class (I called mine com.intellicare.asterisk.Agent.java). Make sure it is serializable (important!).
    Step 2. Open your JaWE editor. Open the xpdl that you want to use.
    Step 3. pull down Package -> Type Declarations. Click "New". Enter: id:agent, name: agent, Type: External reference, Location: com.intellicare.asterisk.Agent. Click OK.
    Step 4. pull down menu Package -> workflow relevant data. Click New. Enter: id: agentWfdata, name: agentWfdata, isArray: false, Type: declared type. The dropdown menu subtype will now appear with your item "agent" in it. Pick that.Click Ok.
    You are done with your xpdl now.
    Now the wf data variable agentWfdata will be available to your Java/Shark app as follows:

    1. In order to access/initialise it within your Java program, here's what you do: Assume you have Shark initialised and your process has started. Assume you have objects WfActivity currentActivity and Agent agent. Then you can update the wfdata variable with agent as follows:

    Map processContextMap = currentActivity.container().process_context();
    processContextMap.put("agentWfdata", agent);
    currentActivity.set_result(processContextMap);
    currentActivity.complete();

    2. Now wf data variable agentWfdata is available to all activities of your process. For example you can declare an application in your xpdl this way:
    step(i) Open your xpdl in JaWE editor. pull down Package -> Application. Enter id:myApp, name:myApp, Then "new" formal parameter with id:agentFormalParam, mode:in and out, type:declared type. Again you should get the choice of "agent" in your drop down menu for decalred type. Click OK. Now suppose one of your activities has "Tools" mapped to this application, then the *actual* parameter that you can map to the formal parameter "agentFormalParam" is "agentWfData". This is because they both are of type decalred type "agent".
    step (ii). Now in your Java/Shark program you can write a toolagent which can access the wfdata "agentWfdata " as follows:
    Assume your toolagent has just that one AppParam, thenwithin the execute method:
    public static void execute(AppParameter param1) {
    Agent agent = (Agent) param1.the_value; //this is ok since we declared this to be *in* and out param
    //now do whatveer you want with agent variable..

    Agent agent2 = new Agent(..blah..);
    param1.value = agent2; //this is ok since we declared this is to be in and *out* param
    //etc..
    }


    收藏到:Del.icio.us




    引用地址:

    引用

    下面Blog引用了该文:

    评论

  • www.sina.com.cn

发表评论

您将收到博主的回复邮件
记住我