Java Actions - Dynamic Java Action
The Dynamic Java Action allows you to call methods on a Java class you have created. Unlike the Java Action, the Dynamic Java Action does not require you to implement any specific interfaces in your code.
To use the Dynamic Java Action, just set the listener and listener signature, and (optionally) any arguments the method may require.
Properties
Argument Count
The total number of arguments expected by the method that this action is calling.
The argument count is dynamically generated based on the listener signature and cannot be updated. You can use the argument count to easily see how many arguments your listener is expecting.
Argument
The actual values will be passed as arguments to the method that this action is calling.
The argument properties contain an indexed collection of values to be passed to the method. The first argument stored in the collection corresponds with the first argument in your listener signature, the second argument in the collection corresponds with the second in the signature, and so on.
To set the argument values, you will first need to set the listener signature property. The argument collection will then be initialized with an empty data set (the exact data types will be automatically determined based on the listener signature), which you can then edit to include the data you are planning to pass in.
The argument property supports variable substitution for passing along data from the workflow (for example, to pass the result of another action as an argument to your listener).
Listener
The name (including the full package) of the listener class that this action will invoke – for example, mypackage.MyDynamicListener. Unlike the Java Action, the listener class for the Dynamic Java Action does not need to implement any Flux interfaces.
This property is used in conjunction with the listener signature to determine which class and method should be invoked when the Dynamic Java Action runs.
Listener Signature
The signature of the method on your listener class that this action will invoke when it executes. The listener signature property should include the method name and any arguments that the method might include.
For example, to invoke the main() method on the listener class, your listener signature property should be set to:
main(String[] args)
If, on the other hand, you wanted to invoke a method whose source code looked like:
public void doSomething(int arg1, String arg2) {
// Your code here
}
Then your listener signature would be set to:
doSomething(int arg1, String arg2)
The Dynamic Java Action can invoke any public method on your listener class (including static methods and main() methods as demonstrated above).
When you set the listener signature, the argument count and argument properties are dynamically updated. You will need to be sure to set the listener signature property correctly before attempting to set any arguments on the property.
For example, if the listener signature was set to the doSomething() method as listed above, then the argument count would automatically be adjusted to “2”, and the argument property would become editable with two arguments available: first, an integer (corresponding with the first argument in the signature), and second, a String (corresponding with the second argument in the signature).
Result
The Dynamic Java Action returns its result in the flow context variable “result”. The result is the Object returned by the invocation of the method specified in the Listener Signature for this action.
Flow Context Variable | Java Type | Description | Prescript / Postscript Example |
---|---|---|---|
RESULT | Object | The Object returned by the method specified in the listener signature. | Object result = flowContext.get("RESULT"); System.out.println(result); |
Passing Results with a Runtime Data Map
You can use a Runtime Data Map to copy one the result into a new variable (for future reference or to reuse the data later in the workflow).
To copy the result, you can use a data map like: