jbpm3的Variable的类型处理

来源:互联网 发布:lol网络不稳定跳ping 编辑:程序博客网 时间:2024/06/07 06:18

我们知道,流程定义中的Variable是要持久化的,比如可能存放到数据库中,那么,类型怎么处理呢?
我们看看jbpm3的方法:
jbpm3定义了自己的类JbpmType,该类有两个属性:
1)public Class variableInstanceClass = null;
它表示该Variable对应于引擎的类型
2)public Converter converter = null;
他表示从引擎的类型与JAVA类型间的转换器

处理时,引擎先到类路径的jbpm.type.properties文件中查找,如果没有,再到
org/jbpm/db/hibernate/jbpm.types.properties文件中查找,该文件是编辑好了的,如下:
# each line contains 2 or 3 class names (transformer-class is optional) separated by a space :
#   variable-class transformer-class variableinstance-class
# or
#   variable-class variableinstance-class

### stored in a text-field in the database###
java.lang.String                                                                      org.jbpm.context.exe.variableinstance.StringInstance
java.lang.Boolean    org.jbpm.context.exe.converter.BooleanToStringConverter      org.jbpm.context.exe.variableinstance.StringInstance
java.lang.Character  org.jbpm.context.exe.converter.CharacterToStringConverter    org.jbpm.context.exe.variableinstance.StringInstance
java.lang.Float      org.jbpm.context.exe.converter.FloatToStringConverter        org.jbpm.context.exe.variableinstance.StringInstance
java.lang.Double     org.jbpm.context.exe.converter.DoubleToStringConverter       org.jbpm.context.exe.variableinstance.StringInstance
java.io.Serializable org.jbpm.context.exe.converter.SerializableToStringConverter org.jbpm.context.exe.variableinstance.StringInstance

### stored in a number-field in the database###
java.lang.Long                                                              org.jbpm.context.exe.variableinstance.LongInstance
java.lang.Byte    org.jbpm.context.exe.converter.ByteToLongConverter    org.jbpm.context.exe.variableinstance.LongInstance
java.lang.Short   org.jbpm.context.exe.converter.ShortToLongConverter   org.jbpm.context.exe.variableinstance.LongInstance
java.lang.Integer org.jbpm.context.exe.converter.IntegerToLongConverter org.jbpm.context.exe.variableinstance.LongInstance
java.util.Date    org.jbpm.context.exe.converter.DateToLongConverter    org.jbpm.context.exe.variableinstance.LongInstance
第一列表示JAVA类型,第三列表示引擎中的类型,而中间的列表示转换器定义

转换器的概念其实非常简单,比如,对于布尔值true,在程序中是一个java.lang.Boolean的类型
的值,但在jbpm3数据库中,它是一个串"T"或者"F",那么就需要一个转换器
org.jbpm.context.exe.converter.BooleanToStringConverter来进行转换.




原创粉丝点击