简体   繁体   中英

How to check null value from Java Method of Tibco ActiveMatrix

I am having a trouble on checking null value from a Java Method component in Tibco ActiveMatrix process.

Basically, I have a Java Method component invoking java to get a billing account, if the return is null, I would like to log the searching criteria - billing account id; otherwise, I will map the object to be XML content...

The problem is while using the following in 'XPath' to check the null object in a transition (Success with condition):

  • empty($Get-BA-Details/ns5:JavaMethodActivityOutput/MethodReturnValue
  • count($Get-BA-Details/ns5:JavaMethodActivityOutput/MethodReturnValue)= 0
  • string-length($Get-BA-Details/ns5:JavaMethodActivityOutput/MethodReturnValue) = 0

'$Get-BA-Details' is the Java Method component.

they all return 'false', and then try to map the java object to be XML content, which results in error while billing account is not found.

Could anyone shed some lights?

Thanks a lot!

Try this:

$Get-BA-Details/ns5:JavaMethodActivityOutput/MethodReturnValue=""

From what I can tell you cannot check if the return from a Java Method activity is null using XPath. Instead you can create a Java Code activity that takes an ObjectReference as an input parameters and provides a boolean as an output parameter. You can then use code like to following to check if the object is null ( object is the input parameter and isnull is the output parameter):

isnull = object == null; 

I have created BWUnit tests in the for this in the latest snapshot of BWUnit, which you can download from http://windyroad.org/software/bwunit/download/BWUnit-11.2.zip

The tests are located at StackOverflow/UnitTestSuite/JavaMethodNullTestCase in the simple example, which is found in Examples/Simple within the download.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM