|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.oddjob.framework.BaseComponent
org.oddjob.framework.BasePrimary
org.oddjob.framework.SimpleJob
org.oddjob.framework.SerializableJob
org.oddjob.jobs.ExecJob
public class ExecJob
Processes may behave differently on different operating systems - for instance stop doesn't always kill the process. Please see http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=4109888 for additional information.
<exec name="Batch Example"> cmd /C "${oddjob.dir}\bin\greeting.bat" Hello </exec>Oddjob will treat arguments in quotes as single program argument and allows them to be escaped with backslash. If this is too confusing it is sometimes easier to specify the command as individual arguments. The above is equivalent to:
<exec name="Batch Example"> <args> <list> <values> <value value="cmd"/> <value value="/C"/> <value value="${oddjob.dir}\bin\greeting.bat"/> <value value="Hello"/> </values> </list> </args> </exec>
<oddjob> <job> <exec name="Example With Environment" id="exec"> <environment> <value key="ODDJOB_FILE" value="myfile.txt"/> </environment> ${platform.set.command} </exec> </job> </oddjob>
<oddjob id="this"> <job> <exec redirectStderr="true"> <stdout> <file file="${work.dir}/ExecOutput.log"/> </stdout> java -jar "${oddjob.run.jar}" -h </exec> </job> </oddjob>
<oddjob id="this"> <job> <exec> <stdout> <logout level="INFO"/> </stdout> <stderr> <logout level="WARN"/> </stderr> java -jar ${oddjob.run.jar} -f Missing.xml </exec> </job> </oddjob>
<oddjob id="this"> <job> <sequential> <jobs> <variables id="vars"> <ourBuffer> <buffer/> </ourBuffer> </variables> <exec> <stdin> <buffer>apples oranges pears </buffer> </stdin> <stdout> <value value="${vars.ourBuffer}"/> </stdout> java -jar "${oddjob.run.jar}" -f "${this.dir}/OddjobCat.xml" </exec> <exec id="exec"> <stdin> <value value="${vars.ourBuffer}"/> </stdin> <stdout> <stdout/> </stdout> java -jar "${oddjob.run.jar}" -f "${this.dir}/OddjobCat.xml" </exec> </jobs> </sequential> </job> </oddjob>
Field Summary |
---|
Fields inherited from class org.oddjob.framework.SimpleJob |
---|
stateHandler, stop |
Fields inherited from class org.oddjob.framework.BaseComponent |
---|
iconHelper |
Constructor Summary | |
---|---|
ExecJob()
|
Method Summary | |
---|---|
ArooaTokenizer |
commandTokenizer()
Provide the ArooaTokenizer to use for parsing commands. |
LogArchive |
consoleLog()
Provide the console archive. |
protected int |
execute()
Execute this job. |
String |
getCommand()
Get the command. |
File |
getDir()
|
String |
getEnvironment(String name)
|
int |
getExitValue()
|
OutputStream |
getStderr()
Get the output stream for stderr. |
InputStream |
getStdin()
Get the input stream for stdin. |
OutputStream |
getStdout()
Get the output stream for stdout. |
boolean |
isNewEnvironment()
|
boolean |
isRedirectStderr()
|
void |
onStop()
Allow sub classes to do something on stop. |
void |
setArgs(String[] args)
Add an argument. |
void |
setCommand(String command)
Set the command to run. |
void |
setDir(File dir)
Set the working directory. |
void |
setEnvironment(String name,
String value)
Add an environment variable. |
void |
setNewEnvironment(boolean explicitEnvironment)
|
void |
setRedirectStderr(boolean redirectErrorStream)
|
void |
setStderr(OutputStream stderr)
Set the output stream stderr from the process will be directed to. |
void |
setStdin(InputStream stdin)
Set the input stream stdin for the process will be read from. |
void |
setStdout(OutputStream stdout)
Set the output stream stdout from the process will be directed to. |
Methods inherited from class org.oddjob.framework.SimpleJob |
---|
fireDestroyedState, force, getStateChanger, hardReset, onDestroy, onReset, run, sleep, softReset, stateHandler, stop |
Methods inherited from class org.oddjob.framework.BasePrimary |
---|
configure, getName, logger, logger, loggerName, save, setName, toString |
Methods inherited from class org.oddjob.framework.BaseComponent |
---|
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.oddjob.Stoppable |
---|
stop |
Methods inherited from interface org.oddjob.Stateful |
---|
addStateListener, lastStateEvent, removeStateListener |
Constructor Detail |
---|
public ExecJob()
Method Detail |
---|
public void setArgs(String[] args)
arg
- The argument.public void setCommand(String command)
command
- The command.public String getCommand()
public void setDir(File dir)
dir
- The working directory.public void setNewEnvironment(boolean explicitEnvironment)
Property: newEnvironment
Description: Create a fresh/clean environment.
Required: No.
public boolean isNewEnvironment()
public void setEnvironment(String name, String value)
nvp
- The name/value pair variable.public String getEnvironment(String name)
public void setRedirectStderr(boolean redirectErrorStream)
Property: redirectStderr
Description: Redirect the standard error stream in standard output.
Required: No.
public boolean isRedirectStderr()
public void setStdin(InputStream stdin)
stdin
- An InputStream.public InputStream getStdin()
public void setStdout(OutputStream stdout)
stdout
- The output stream.public OutputStream getStdout()
public void setStderr(OutputStream stderr)
stderr
- The error stream.public OutputStream getStderr()
public ArooaTokenizer commandTokenizer()
ArooaTokenizer
to use for parsing commands.
protected int execute() throws Exception
SimpleJob
execute
in class SimpleJob
Exception
- If the unexpected occurs.public void onStop()
SimpleJob
onStop
in class SimpleJob
public File getDir()
public int getExitValue()
public LogArchive consoleLog()
ConsoleOwner
consoleLog
in interface ConsoleOwner
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |