IBM Support

How to call Java POJO from BPM Standard?

Question & Answer


Question

How to call Java POJO from BPM Standard?

Answer

Java integration can be accomplished via Java Integration or LiveConnect directly from Java Script.

Starting with BPM 8.5.7 and usage of Web Designer, using Live Connect is the recommended method: https://www.ibm.com/support/knowledgecenter/en/SSFTN5_8.5.7/com.ibm.wbpm.main.doc/topics/rdev_jsapi_callingjavathroughjavascript.html.

When using Java Integration you can call any SINGLE java class method which uses arguments that can be directly mapped to BPM objects and the class has an empty constructor.
For more information
see http://www.ibm.com/support/knowledgecenter/SSFTN5_8.5.5/com.ibm.wbpm.wle.editor.doc/topics/building_java_integration_service.html?cp=SSFTDH_8.5.5&lang=en
and Mapping between BPM JS variables and Java Integration parameters article.

If the java method you want to call takes a complex Java Class argument which can not be directly mapped to BPM object then you have couple of options on how to call these type of method

For example:  let's say you want to call a method:
            public static void print( SimpleStructure s)
where  SimpleStructure class have a public constructor
            public SimpleStructure( String inS int inI boolean inB double inD )

SimpleStructure can not be directly mapped to Business Object thus this method can not be called directly via Java Integration

1)  You can create a wrapper java class which uses a facade to expose arguments accessible via Java Integration.
Create a class with public method printSimplStructure( String inS int inI boolean inB double inD ).
Inside this method create the instance of SimpleStructure and call the print( SimpleStructure s).

2) You can create a wrapper class which takes a TWObject as argument for example:
            printSimpleStructureBO( TWObject bo )
The TWObject java class directly maps to the Process Designer Business Object.
Inside the method you can access the properties of the Business object get the data create the SimpleStructure object and call print( SimpleStructure s)
Following KC article explain how to work with TWObjectFactory TWObject and TWList classes

3) You can use LiveConnect to call Java directly from Java Script.
.


 4) you can use tw.object.Map business object which maps to java.util.Map java interface to pass multiple arguments into java wrapper method.

Note: you can not save the Java reference when using Java Integration.  If multiple calls to the same java object are required you need to create a wrapper class/method to expose the functionality in a stateless pattern.
For example for java code:
SimpleStructure s = new SimpleStructure()
s.setStr("a")
s.setI(1)
s.toString()


Please note that all classes which are part of the Managed Assets are loaded by a BPM internal class loader.  Each snapshot ( either application or toolkit ) uses different class loader instances.

If you really need a singleton implementation with JVM scope add the jar file to each App Target Cluster JVM class path.? For example copy the jar into WAS_HOME/lib/ext directory is loaded via single bootstrap class loader.  Another option is to create a shared library.
 

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSQTW3","label":"IBM On Demand Consulting for Hybrid Cloud"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"","label":""}}]

Document Information

More support for:
IBM On Demand Consulting for Hybrid Cloud

Software version:
All Versions

Document number:
778907

Modified date:
22 March 2019

UID

ibm10778907

Manage My Notification Subscriptions