看似是一个variable有name和mapped-name两个名称,其实情况很复杂。看例子。
假定我们有一个极其简单的流程vartest (surprisingly it also means V-Artest, but i must say that i'm not a Laker fan) 。在start-state的controller里添加一个variable,name为"var",mapped-name为"variable",如下:
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="" name="vartest">
<start-state name="start-state1">
<task>
<controller>
<variable access="read,write" name="var" mapped-name="variable"></variable>
</controller>
</task>
<transition to="task-node1"></transition>
</start-state>
<task-node name="task-node1"
<transition to="end-state1"></transition>
</task-node>
<end-state name="end-state1"></end-state>
</process-definition>
然后我们来写一个Test Case:
public class AccessVariable extends TestCase
{
public void testPayProcess() throws Exception
{
JbpmContext jc = JbpmConfiguration.getInstance().
createJbpmContext();
ProcessDefinition pd = jc.getGraphSession().
findLatestProcessDefinition("vartest");
ProcessInstance pi = pd.createProcessInstance();
ContextInstance ci = pi.getContextInstance();
TaskInstance ti = pi.getTaskMgmtInstance().createStartTaskInstance()
//hint 1:
//ci can create new variable (not declared in <controller>)
//and ti can access the variable ci created
ci.setVariable("abc", "ABC");
System.out.println(ti.getVariable("abc")); //ABC
ti.setVariable("abc", "CBA");
System.out.println(ci.getVariable("abc")); //CBA
//hint 1:
//also, ti can create this kind of variables
//and ci can access the variable ti created
ti.setVariable("def", "DEF");
System.out.println(ci.getVariable("def")); //DEF
ci.setVariable("def", "FED");
System.out.println(ti.getVariable("def")); //FED
//hint 2:
//for the variables declared in <controller>, it's the same situation
//both ci and ti can create and access this kind of variable
ci.setVariable("var", "VAR");
System.out.println(ti.getVariable("var")); //VAR
ti.setVariable("var", "RAV");
System.out.println(ci.getVariable("var")); //RAV
//hint 3:
//"var" doesn't affect "variable"
System.out.println(ti.getVariable("variable")); //null
System.out.println(ci.getVariable("variable")); //null
//hint 4:
//things becaome a little different when using mapped-name
ti.setVariable("variable", "VARIABLE");
System.out.println(ti.getVariable("variable")); //VARIABLE
System.out.println(ci.getVariable("variable")); //null
//hint 4:
//it's clear that ti and ci both holds an "variable", respectively
ci.setVariable("variable", "ELBAIRAV");
System.out.println(ti.getVariable("variable")); //VARIABLE
System.out.println(ci.getVariable("variable")); //ELBAIRAV
//hint 3:
//and "variable" doesn't affect "var"
System.out.println(ti.getVariable("var")); //RAV
System.out.println(ci.getVariable("var")); //RAV
ti.end();
pi.end();
jc.close();
}
}
输出结果如注释所示。
可以看出,除了mapped-name之外,ti和ci可以随意SetVariable(key, value),SetVariable的过程包含了create的过程,key可以是name,也可以是其他字符串,且这种类型的变量(名称为name或是任意字符串,只要不是mapped-name)ti和ci可以随意访问,这类变量对ti和ci的作用域是一样的(类似于全局变量)。
但name和mapped-name变量没有任何关系,如hint 3所示,"var"的值不会影响"variable",反过来"variable"的值也不会影响"var"。
且mapped-name变量对ti和ci来说更像是2个变量,其作用域严格区分,没有任何交集,如hint 4所示。
分享到:
相关推荐
$ npm i --save @nestjs/mapped-types 快速开始 构建功能时,在基本实体类型上构建变体通常很有用。 这种变体的一个很好的例子是数据传输对象(DTO)。 数据传输对象是用于封装数据并将其从应用程序的一部分发送到...
go-mapped-csv 类似于stdlib的encoding / csv,不同之处在于它根据传递的列编写映射。 查看。 执照 麻省理工学院
本代码用来对WinCE环境下内存映射的读写,当在系统总线上扩展新的硬件设备时会非常重要。
映射国家语言代码具有相应语言的国家/地区的哈希值和具有相应国家/地区的语言的哈希值。 包括全名和代码哈希。 ISO 3166-1 和 639-1 我在一个项目中需要这个,但在网络上的任何地方都找不到它,所以我做了一些爬行并...
前几天在网上下载一个struts2的helloword的例子,那个作者也真够缺德的,搞个错误的程序,害得我查了一天的程序错误。 最后发现竟然是struts.xml被写成啦sturts.xml。 碰见这样的问题先鄙视下提供例子的作者, ...
0x000080e4 : 0xe52d0004 str r0, [sp, #-4]!; 0x000080e8 : 0xe59f0010 ldr r0, [pc, #16]; 0x000080ec : 0xe59f3010 ldr r3, [pc, #16]; 0x000080f0 : 0xe52dc004 str ip, [sp, #-4]!; 0x000080f4 : 0xeb00003c bl...
映射模块:概念验证 该文件夹通过模块作为映射名称来展示ESM。 modules.json文件导出的名称可用作ESM导入。 { "module" : "/js/hello-world.js" } 例如,现在可以通过以下命令导入/js/hello-world.js : ...
资源来自pypi官网。 资源全名:mapped_config-2.34-py2-none-any.whl
MDB: A Memory-Mapped Database and Backend for OpenLDAP
现在,可以使用规范化的字段名称将这些数据直接映射到您自己的Django模型和表单。 一个常见的用例是从外部系统获取CSV或JSON文件,并将它们规范化为您自己的数据结构。 用法 要使用地图字段,只需将其导入并在创建...
MemoryMappedFile 使用 C# 内存中分配一大块地址. 前边分配一个用与共同配置用 后边N个结构体 for循环建 一般用到此问题,两本程序 一个读一个写 循环读写 ----2015/09/24 Lyndon 上海----
prefer-mapped-imports规则导入外部模块或ES6导入声明时,建议使用映射路径。 注意:此规则适用于选件prefix指定映射的导入的前缀(通常为“ @ src /”)。 prefix-mapped-to指定映射到前缀的文件夹(通常是“ src /...
Memory-Mapped Files for Qualcomm Brew By Ray Rischpater
Life After BerkeleyDB- OpenLDAP's Memory-Mapped Database
基于.NET4.0的MemoryMappedFile实现共享内存通信 共享内存通信可以解决跨线程、跨进程、跨EXE之间通信的问题 对于需要传输图片等引用类数据,可以通过序列化和反序列化配合共享内存实现跨进程(跨EXE)通信 共享...
#launch 5 containers, host volume mapped to /opt/data/ubuntu-N $ launch-docker-containers ubuntu mytag 5 #stop only containers named ubuntu $ stop-docker-containers ubunt* #stop and remove containers ...
利用Memory Mapped File实践A,B跨程序的数据交换
--------------------------------------------------------------------------------...Map with errors mapped from fieldname (String) to Collection of String error messages ---------------------------------...
Returns the object bound with the specified name in this session, or null if no object is bound under the name. getAttributeNames() - Method in interface javax.servlet.ServletContext Returns an ...