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.
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 1 | Invoking a method on a bean. |
Example 2 | Invoking a static method. |
Example 3 | Examples elsewhere. |
Configured By | ELEMENT |
Access | READ_WRITE |
Required | Must 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.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | Yes. |
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).
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. |
A name, can be any text.
Configured By | ELEMENT |
Access | READ_WRITE |
Required | Must match the expected arguments. |
The values to use as arguments. Note that the
args
property may be more convenient for simple arguments.
Access | READ_ONLY |
Configured By | ELEMENT |
Access | READ_WRITE |
Required | Yes. |
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.
Access | READ_ONLY |
Required | Read Only. |
This flag is set by the stop method and should be examined by any Stoppable jobs in their processing loops.
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
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>
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.