IBM BPM Introspection


Many programming languages allow introspection to examine objects at runtime. Even Javascript has this ability but IBM BPM does not have this built in. To workaround this limitation a service can be built with an input type of ANY and output to a specific data type required.

Example Use

One of the uses I had for introspection was for a project to generate documents which had place holders in the template. These place holders required a value substitution when they were generated.

I used the syntax [ObjectPropertyName] as the place holder. For example a document may contain [Customername] and a variable of type Customer can be passed in containing the attribute name. The service would return <"Name", "Mr Smith"> as one of the values in the map and can be easily used to parse the template document and use the key in the map to get the value to replace the place holder with the actual value.

Introspection Service

A Server Script is all that is required with the following code:

if(tw.local.variable != null) {
tw.local.variableValues.objectValues = new tw.object.Map();

// Convert variable to XML object
var myVar = tw.system.serializer.toXml(tw.local.variable);

// Get Data type name
/* Bellow can syntax can be used to retrieve the data type name

for (var loop = 0; loop < myVar.childNotes.length; loop++) { /* below are syntax for getting the variable data type myVar.childNodes.item(loop).getAttribute("type");*/ // Add variable name and value to the map tw.local.variableValues.objectValues.put(myVar.getAttribute("tagName"), myVar.getAttribute("type")); } }

Unfortunately all the values will be returned as String type so all of them must be parsed back to a native variable if necessary. The variable type information can be retrieved to determine which type it needs to be converted to.


The above shows a way to perform introspection on an object at runtime as a starting point. It may be expanded to simulate reflection by passing the object in, introspect and manipulate before passing it back out.

About Danny

I.T software professional always studying and applying the knowledge gained and one way of doing this is to blog. Danny also has participates in a part time project called Energy@Home [] for monitoring energy usage on a premise. Dedicated to I.T since studying pure Information Technology since the age of 16, Danny Tsang working in the field that he has aimed for since leaving school. View all posts by Danny → This entry was posted in IBM BPM and tagged , , , , , . Bookmark the permalink.

Leave a Reply