Accessing Java object properties from custom Java function in TIBCO BusinessEvents .

Accessing Java object properties from custom Java function in TIBCO BusinessEvents .

book

Article ID: KB0090689

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition -
Not Applicable -

Description

Resolution:
Description:
===========
Accessing Java object properties from custom Java function in TIBCO BusinessEvents .

Environment:
===========
All Operating Systems
TIBCO BusinessEvents 4.x,5.x


Resolution:
===========
Returning an object from an external custom Java function is possible in TIBCO BusinessEvents but its not possible to access the properties of the object directly. To do this the object properties of the custom Java object must be returned as a string (from the custom function) with a delimiter. This string can then be parsed using the function String.tokenize() with the delimiter used in the custom Java function to get the property values and set them in the TIBCO BusinessEvents code .

Custom Function Code :

package com.test;
public class ObjectReturn {

public static void main(String args[]) {
  objectReturn();
}

public static Object objectReturn() {
  Person person = new Person("Fedex", "USA");
  System.out.println("ObjectReturn.objectReturn()");
  return person.name + "$" + person.location; // Please note that the delimiter used in this case is $
}
}
//Custom java object
class Person {
// The custom java object has the properties name and location
String name;
String location;

Person(String name, String location) {
  this.name = name;
  this.location = location;
}

public String getName() {
  return name;
}

public void setName(String name) {
  this.name = name;
}

public String getLocation() {
  return location;
}

public void setLocation(String location) {
  this.location = location;
}
}

Code to extract the property values for name and location in TIBCO BusinessEvents :

Object javaObjectPropertiesString = Testing.ObjReturn(); // Invoking custom java function
String[] properties = String.tokenize(javaObjectPropertiesString , "$"); // Please note that the delimiter used in this case is $
Concepts.Person.Person("ExtID",properties[0],properties[1]);

Concepts.Person beconcept = Instance.getByExtId("ExtID");
System.debugOut(beconcept.Name);
System.debugOut(beconcept.Location);

Issue/Introduction

Accessing Java object properties from custom Java function in TIBCO BusinessEvents .