(TIBCO BusinessWorks) How do you access a Java Global Instance method from a Java Code activity?

StackOverflow https://stackoverflow.com/questions/808920

  •  03-07-2019
  •  | 
  •  

Question

The TIBCO ActiveMatrix BusinessWorks Palette Reference states:

"Any Java Code activity can access the shared Java Global Instance by invoking the static methods of the configured Java class", however, I've been unable to locate any code examples for doing this, or figure out the correct syntax on my own.

What doesn't work:

method();
Class.method();

What does work:

I dunno, that's why I'm here :)

Was it helpful?

Solution

If you have the following class referenced in an AliasLibrary:

com.example.foo.Foo

and it has a static method bar(), then you can call that in a Java Code activity by simply using:

com.example.foo.Foo.bar();

in your Java Code activity. Make sure you reference AliasLibrary in the Java Code configuration panel.

You can do this without using a Java Global Instance. Which is what you'd expect that for a static method....you shouldn't need an object reference.

OTHER TIPS

  1. In your project, add an AliasLibrary task from the General palette. Add the jar file to the AliasLibrary containing the Class you want to access.

  2. Within a BusinessWorks process activity, drag a "Java Method" task onto the canvas. Use the configuration tab to specify the AliasLibrary and then use the finder to locate the Class and method you wish to invoke. The "Advanced" tab gives you some options for managing the java instance lifecycle associated with this method call.

Optionally, if you want to instantiate a global java instance which is shared among multiple jobs/processes, then use the "Java Global Instance" task from the Java palette. In the configuration tab, point to the AliasLibrary and use the finder to locate the Class and static method you want to execute. The "Java Method" task can be used to invoke a method on this global instance.

The "Java Global Instance" may also be necessary if you don't have a default constructor on your java class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top