public class InvokeType extends Object implements ArooaValue, ArooaSessionAware
For a script, the source must be a javax.script.Invocable
object.
<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!
<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>
ScriptJob
examples.Modifier and Type | Class and Description |
---|---|
static class |
InvokeType.Conversions
Conversions.
|
Constructor and Description |
---|
InvokeType() |
Modifier and Type | Method and Description |
---|---|
Object[] |
getArgs() |
String |
getFunction() |
ArooaValue |
getParameters(int index) |
Invoker |
getSource() |
void |
setArgs(Object[] args) |
void |
setArooaSession(ArooaSession session) |
void |
setFunction(String function) |
void |
setParameters(int index,
ArooaValue parameter) |
void |
setSource(Invoker source) |
String |
toString() |
Object |
toValue() |
public void setArooaSession(ArooaSession session)
setArooaSession
in interface ArooaSessionAware
public Invoker getSource()
public void setSource(Invoker source)
public String getFunction()
public void setFunction(String function)
public ArooaValue getParameters(int index)
public void setParameters(int index, ArooaValue parameter)
public Object[] getArgs()
public void setArgs(Object[] args)