Package org.oddjob.script
Class InvokeJob
- All Implemented Interfaces:
Serializable,Runnable,ArooaContextAware,ArooaSessionAware,Forceable,PropertyChangeNotifier,Iconic,LogEnabled,Resettable,Stateful,Stoppable
- Author:
- rob
- See Also:
Description
Invoke a java method or script snippet.
This is a wrapper for InvokeType. 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.
Example
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', classloader=java.net.URLClassLoader@5d6cac57
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 InvokeType for several more examples. Property configuration
is the same for the type and the job.
The JMXServiceJob job has an example of
invoking a JMX operation.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intexecute()Execute this job.Object[]getArgs()getParameters(int index) protected voidonReset()Allow sub classes to do something on reset.protected voidonStop()Allow sub classes to do something on stop.voidvoidsetFunction(String function) voidsetParameters(int index, ArooaValue parameter) voidMethods inherited from class org.oddjob.framework.extend.SimpleJob
fireDestroyedState, force, getStateChanger, hardReset, iconHelper, isStop, onDestroy, run, sleep, softReset, stateHandler, stopMethods inherited from class org.oddjob.framework.extend.BasePrimary
configure, getName, logger, logger, loggerName, save, setName, toStringMethods inherited from class org.oddjob.framework.extend.BaseComponent
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSessionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.oddjob.Stateful
addStateListener, lastStateEvent, removeStateListener
-
Constructor Details
-
InvokeJob
public InvokeJob()Constructor.
-
-
Method Details
-
execute
Description copied from class:SimpleJobExecute this job. -
onReset
protected void onReset()Description copied from class:SimpleJobAllow sub classes to do something on reset. -
onStop
Description copied from class:SimpleJobAllow sub classes to do something on stop.- Overrides:
onStopin classSimpleJob- Throws:
FailedToStopException
-
getSource
-
setSource
-
getFunction
-
setFunction
-
getParameters
-
setParameters
-
getArgs
-
setArgs
-
getResult
-