public class InvokeType extends java.lang.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 |
---|---|
java.lang.Object[] |
getArgs() |
java.lang.String |
getFunction() |
ArooaValue |
getParameters(int index) |
Invoker |
getSource() |
void |
setArgs(java.lang.Object[] args) |
void |
setArooaSession(ArooaSession session)
Accept the current Arooa Session.
|
void |
setFunction(java.lang.String function) |
void |
setParameters(int index,
ArooaValue parameter) |
void |
setSource(Invoker source) |
java.lang.String |
toString() |
java.lang.Object |
toValue() |
public void setArooaSession(ArooaSession session)
ArooaSessionAware
setArooaSession
in interface ArooaSessionAware
session
- The Arooa Session. Never null.public java.lang.Object toValue() throws java.lang.Throwable
java.lang.Throwable
public Invoker getSource()
public void setSource(Invoker source)
public java.lang.String getFunction()
public void setFunction(java.lang.String function)
public ArooaValue getParameters(int index)
public void setParameters(int index, ArooaValue parameter)
public java.lang.Object[] getArgs()
public void setArgs(java.lang.Object[] args)
public java.lang.String toString()
toString
in class java.lang.Object