Class ExecBase

All Implemented Interfaces:
Serializable, Runnable, ArooaContextAware, ArooaSessionAware, Forceable, PropertyChangeNotifier, Iconic, ConsoleOwner, LogEnabled, Resettable, Stateful, Stoppable
Direct Known Subclasses:
ExecJob, JavaJob

public abstract class ExecBase extends SerializableJob implements Stoppable, ConsoleOwner
Base class for Jobs that create an external process.
Author:
Rob Gordon.
See Also:
  • Constructor Details

    • ExecBase

      public ExecBase()
  • Method Details

    • setDir

      public void setDir(File dir)
      Set the working directory.
      Parameters:
      dir - The working directory.
    • setNewEnvironment

      public void setNewEnvironment(boolean explicitEnvironment)
      Reference Property:
      newEnvironment

      Description

      Create a fresh/clean environment.
      Required:
      No.
    • isNewEnvironment

      public boolean isNewEnvironment()
    • setEnvironment

      public void setEnvironment(String name, String value)
      Add an environment variable.
      Parameters:
      name - The of the environment variable.
      value - The value of the environment variable.
    • getEnvironment

      public String getEnvironment(String name)
    • setRedirectStderr

      public void setRedirectStderr(boolean redirectErrorStream)
      Reference Property:
      redirectStderr

      Description

      Redirect the standard error stream in standard output.
      Required:
      No.
    • isRedirectStderr

      public boolean isRedirectStderr()
    • setStdin

      public void setStdin(InputStream stdin)
      Set the input stream stdin for the process will be read from.
      Parameters:
      stdin - An InputStream.
    • getStdin

      public InputStream getStdin()
      Get the input stream for stdin. This will be null unless one has been provided.
      Returns:
      An InputStream or null.
    • setStdout

      public void setStdout(OutputStream stdout)
      Set the output stream stdout from the process will be directed to.
      Parameters:
      stdout - The output stream.
    • getStdout

      public OutputStream getStdout()
      Get the output stream for stdout. This will be null unless one has been provided.
      Returns:
      An OutputStream or null.
    • setStderr

      public void setStderr(OutputStream stderr)
      Set the output stream stderr from the process will be directed to.
      Parameters:
      stderr - The error stream.
    • getStderr

      public OutputStream getStderr()
      Get the output stream for stderr. This will be null unless one has been provided.
      Returns:
      An OutputStream or null.
    • isStopForcibly

      public boolean isStopForcibly()
    • setStopForcibly

      public void setStopForcibly(boolean stopForcibly)
    • commandTokenizer

      public ArooaTokenizer commandTokenizer()
      Provide the ArooaTokenizer to use for parsing commands.
      Returns:
      A tokenizer, never null.
    • provideArgs

      protected abstract String[] provideArgs() throws Exception
      Throws:
      Exception
    • execute

      protected int execute() throws Exception
      Description copied from class: SimpleJob
      Execute this job.
      Specified by:
      execute in class SimpleJob
      Returns:
      0 if the job is complete, anything else otherwise.
      Throws:
      Exception - If the unexpected occurs.
    • onStop

      public void onStop()
      Description copied from class: SimpleJob
      Allow sub classes to do something on stop.
      Overrides:
      onStop in class SimpleJob
    • getDir

      public File getDir()
      Returns:
      Returns the dir.
    • getExitValue

      public int getExitValue()
    • consoleLog

      public LogArchive consoleLog()
      Description copied from interface: ConsoleOwner
      Provide the console archive.
      Specified by:
      consoleLog in interface ConsoleOwner
      Returns:
      The archive. Must not be null.