简体   繁体   English

如何从Tibco ActiveMatrix的Java方法检查空值

[英]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. 我在检查Tibco ActiveMatrix流程中的Java方法组件中的空值时遇到麻烦。

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; 基本上,我有一个Java方法组件来调用Java以获取一个计费帐户,如果返回值为null,我想记录搜索条件-计费帐户ID; otherwise, I will map the object to be XML content... 否则,我将对象映射为XML内容...

The problem is while using the following in 'XPath' to check the null object in a transition (Success with condition): 问题是在“ XPath”中使用以下命令检查转换中的空对象时(条件成功):

  • empty($Get-BA-Details/ns5:JavaMethodActivityOutput/MethodReturnValue 空($ Get-BA-Details / ns5:JavaMethodActivityOutput / MethodReturnValue
  • count($Get-BA-Details/ns5:JavaMethodActivityOutput/MethodReturnValue)= 0 count($ Get-BA-Details / ns5:JavaMethodActivityOutput / MethodReturnValue)= 0
  • string-length($Get-BA-Details/ns5:JavaMethodActivityOutput/MethodReturnValue) = 0 字符串长度($ Get-BA-Details / ns5:JavaMethodActivityOutput / MethodReturnValue)= 0

'$Get-BA-Details' is the Java Method component. “ $ Get-BA-Details”是Java方法组件。

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. 它们都返回'false',然后尝试将java对象映射为XML内容,这在找不到计费帐户时会导致错误。

Could anyone shed some lights? 有人可以照明吗?

Thanks a lot! 非常感谢!

Try this: 尝试这个:

$Get-BA-Details/ns5:JavaMethodActivityOutput/MethodReturnValue="" $ 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. 据我所知,您无法使用XPath检查Java Method活动的返回是否为null Instead you can create a Java Code activity that takes an ObjectReference as an input parameters and provides a boolean as an output parameter. 相反,您可以创建一个Java Code活动,该活动将ObjectReference作为输入参数,并提供boolean作为输出参数。 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): 然后,您可以使用类似下面的代码来检查对象是否为nullobject是输入参数,而isnull是输出参数):

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 我已经在最新的BWUnit快照中为此创建了BWUnit测试,可以从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. 这些测试位于简单示例中的StackOverflow/UnitTestSuite/JavaMethodNullTestCase ,可以在下载的Examples/Simple找到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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