[Index]

invoke


Invoke a java method or script snippet.

This is a wrapper for invoke. The result of the invocation is placed in the result property.

Note that stopping this job will simply attempt to interrupt the thread invoking the method. The outcome of this will obviously vary.

Oddjob will do it's best to convert arguments to the signature of the method or operation. An exception will result if it can't achieve this.


Property Summary

args An alternative configuration for the values to use as arguments.
function The function/method/operation name to call.
name A name, can be any text.
parameters The values to use as arguments.
result  
source The java object or script Invocable on which to invoke the method/function.
stop This flag is set by the stop method and should be examined by any Stoppable jobs in their processing loops.

Example Summary

Example 1 Invoking a method on a bean.
Example 2 Invoking a static method.
Example 3 Examples elsewhere.

Property Detail

args

Configured ByELEMENT
AccessREAD_WRITE
RequiredMust match the expected arguments.

An alternative configuration for the values to use as arguments. This was added for convenience as setting up a lot of simple arguments can be tedious. If this property is provided then parameters is ignored.

function

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredYes.

The function/method/operation name to call. Note that for a Java static method the method name must be prefixed with the word static (see InvokeType examples).

name

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

A name, can be any text.

parameters

Configured ByELEMENT
AccessREAD_WRITE
RequiredMust match the expected arguments.

The values to use as arguments. Note that the args property may be more convenient for simple arguments.

result

AccessREAD_ONLY

source

Configured ByELEMENT
AccessREAD_WRITE
RequiredYes.

The java object or script Invocable on which to invoke the method/function. If the method is a Java static method then this is the class on which to invoke the method.

stop

AccessREAD_ONLY
RequiredRead Only.

This flag is set by the stop method and should be examined by any Stoppable jobs in their processing loops.


Examples

Example 1

Invoking a method on a bean.

<oddjob>
    <job>
        <sequential>
            <jobs>
                <invoke id="invoke-job" function="echo">
                    <source>
                        <bean class="org.oddjob.script.EchoService"/>
                    </source>
                    <parameters>
                        <value value="Hello"/>
                    </parameters>
                </invoke>
                <echo id="echo">${invoke-job.result}</echo>
            </jobs>
        </sequential>
    </job>
</oddjob>
Where EchoService is:

java.io.IOException: No Resource found: org/oddjob/script/EchoService.java

Example 2

Invoking a static method. Note that this uses args instead of parameters for convenience.

<oddjob>
    <job>
        <invoke function="static totalPrice" id="invoke-totalPrice">
            <args>
                <tokenizer text="Red Apples, 24, 47.3"/>
            </args>
            <source>
                <class name="org.oddjob.script.InvokeJobTest"/>
            </source>
        </invoke>
    </job>
</oddjob>

Example 3

Examples elsewhere.

See invoke for several more examples. Property configuration is the same for the type and the job.

The jmx:service job has an example of invoking a JMX operation.


(c) Rob Gordon 2005 - 2017