Package org.oddjob.script
Class InvokeType
java.lang.Object
org.oddjob.script.InvokeType
- All Implemented Interfaces:
ArooaValue,ArooaSessionAware
- Author:
- Rob.
Description
Invoke a java method or script snippet, or JMX operation.
For a script, the source must be a javax.script.Invocable
object.
Example
Invoke a method on a bean. The method takes a single date parameter which is uses to generate a time of day dependent greeting.
<oddjob>
<job>
<sequential>
<jobs>
<variables id="vars">
<message>
<invoke function="greeting">
<source>
<bean class="org.oddjob.script.GreetingService"/>
</source>
<parameters>
<schedule>
<date>
<value value="${date}"/>
</date>
<schedule>
<schedules:now xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>
</schedule>
</schedule>
</parameters>
</invoke>
</message>
</variables>
<echo id="echo-greeting">${vars.message}</echo>
</jobs>
</sequential>
</job>
</oddjob>
The ${date} reference is there so that it can be injected
during a test, to get a guaranteed result. When this is example
is run as is, this is null so the system clock to be used
there by giving a real time based greeting.
One subtle point to note about Oddjob configuration that this example
highlights is to do with when types are resolved.
The invoke type will be resolved when the
echo job is run. The schedule type will be resolved when the
variables job is
run. If the echo job were scheduled to run several hours after
the variables job had run it would not give the correct greeting!Invoke a static method of a class.
<oddjob>
<job>
<sequential>
<jobs>
<variables id="vars">
<message>
<invoke function="static greetPerson">
<source>
<class name="org.oddjob.script.GreetingService"/>
</source>
<parameters>
<value value="John"/>
</parameters>
</invoke>
</message>
</variables>
<echo id="echo-greeting">${vars.message}</echo>
</jobs>
</sequential>
</job>
</oddjob>
Invoking a function of a script.
See the ScriptJob examples.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionObject[]getArgs()getParameters(int index) voidvoidsetArooaSession(ArooaSession session) Accept the current Arooa Session.voidsetFunction(String function) voidsetParameters(int index, ArooaValue parameter) voidtoString()toValue()
-
Constructor Details
-
InvokeType
public InvokeType()
-
-
Method Details
-
setArooaSession
Description copied from interface:ArooaSessionAwareAccept the current Arooa Session.- Specified by:
setArooaSessionin interfaceArooaSessionAware- Parameters:
session- The Arooa Session. Never null.
-
toValue
- Throws:
Throwable
-
getSource
-
setSource
-
getFunction
-
setFunction
-
getParameters
-
setParameters
-
getArgs
-
setArgs
-
toString
-