- When setting a value for a variable, I can specify the type of the value, even if the value is null
- When getting a value for a variable, I can get the type of the value, even if the value is null
- Also works if the value is a deserialized Java Object
- Also works if the value is a serialized Java Object
Currently the process engine provides an "untyped" API for working with variables.This leads to some subtle limitations:
1) It is impossible to initialize a variable with "null" and declare a type for it:
=> type of variable cannot be detected by process engine and will be "null"
2) It is impossible to get the type of a variable which has variable null. I cannot
Object object = execution.getVariable("myVar");
object.getClass() // < will throw NPE if object is null
All of this is OK as long as I am "only" writing Java Applications in which I know the types of my variables everywhere. However, it causes problems when
- developing a clean REST API
- developing "Generic" applications such as Cockpit or Tasklist
- crossing the language barrier and use Java Script (for instance when developing task forms)
1) It is impossible to attach and retrieve additional metadata to values. For instance, when working with XML data, you cannot specify additional metadata in the variable value such as Namespace / Schema information.
While this can be to a certain extend embedded in the value itself when working with XML this is not trivially possible when working with other dataformats such as JSON or CSV...
2) Additional Metadata is also relevant when working with serialized Java Objects. There the requirement is to be able to get and set the type of the java object even if the object itself is
b) not deserialized (this is required in situations where we cannot deserialize the java objects due to classloader restrictions)
c) specify the value in a different format such as JSON or XML
3) Formulating restrictions (read-only, type-change allowed ...)