Java Actions - Java Action

The Java Action is used to execute Java code. To run your own Java code using this action, you will need to create a special class (called a listener class) that extends flux.ActionListener (see listener below for more details). The code from the actionFired() method of your listener class is executed when this action runs.

You can also pass in an optional key to provide data to your listener code. This is useful, for example, when you need to execute your code using data that is generated at the workflow runs.



The name (including the full package) of the listener class that this action will invoke – for example, mypackage.MyListener.

To invoke a listener class using the Java Action, the class must implement the flux.ActionListener interface. If you need to execute code from a class that does not implement this interface, you must use the Dynamic Java Action.

When the Java Action runs, it will execute the code from the actionFired() method of the listener class. As an example, the source code for a listener class could look something like:

    public  class MyJobListener implements ActionListener {
        public Object actionFired(KeyFlowContext flowContext) throws Exception {
            System.out.println("My Listener has fired.");

            //      Your code here...

            return null;

The KeyFlowContext object passed into the actionFired() method contains information about the current state of execution in the workflow at the time the Java Action runs. You can find more information about this object by viewing the Javadoc for flux.KeyFlowContext.

You can also use the getKey() method of KeyFlowContext to access any key that is provided to the Java Action. This will return the key object (if any) that was set on the Java Action.


The key is an optional piece of data that can be passed to the listener code. The key can be any Java object that supports the Flux rules for persistent variables.

You can set the key to a static value when you create the workflow, or use Runtime Data Mapping to pass in the key-value from another action in the flow chart (for example, to pass the result of a previous action to your Java listener code).


The Java Action returns its result in the flow context variable “result”. The result is the Java object returned from the Listener method this action invoked.

Flow Context Variable Java Type Description Prescript / Postscript Example
RESULT Object The Object returned from the actionFired() method of the Listener class that this Java Action invokes. Object result = flowContext.get("RESULT"); System.out.println("Return Value: " + result);

Passing Results with a Runtime Data Map

You can use a Runtime Data Map to copy 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:

Instruction 1 of 1