views:

810

answers:

2

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 :)

+1  A: 
  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.

scaganoff
That works for the Java Method activity, but what about a Java Code activity?
sangretu
+1  A: 

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.

scaganoff
That's useful as a workaround (AliasLibrary instead of Java Global Instance), but the documentation specifically states that a JGI will function this way. Is it wrong, or am I missing something obvious?
sangretu
I think the documentation is incorrect.
scaganoff
Fair enough ;) Thanks for helping!
sangretu