Class CommandRunner

  • All Implemented Interfaces:
    Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, SizeOfHandler, RemoteCommandProcessorHandler, Serializable

    public class CommandRunner
    extends AbstractOptionHandler
    implements RemoteCommandProcessorHandler
    Executes scripting commands.

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -start-local-engine <boolean> (property: startLocalEngine)
        If enabled, starts the local scripting engine.
        default: false
     
    -engine <adams.scripting.engine.RemoteScriptingEngine> (property: engine)
        The remote scripting engine to use for processing, e.g., responses.
        default: adams.scripting.engine.DefaultScriptingEngine -permission-handler adams.scripting.permissionhandler.AllowAll -request-handler adams.scripting.requesthandler.LoggingHandler -response-handler adams.scripting.responsehandler.LoggingHandler
     
    -connection <adams.scripting.connection.Connection> (property: connection)
        The connection to use for sending the commands to the remote host.
        default: adams.scripting.connection.DefaultConnection
     
    -command <adams.scripting.command.RemoteCommand> [-command ...] (property: commands)
        The remote commands to execute one after the other.
        default: 
     
    -time-out <int> (property: timeOut)
        The grace period in msec to wait for commands to finish before shutting 
        down.
        default: 10000
        minimum: 1
     
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_StartLocalEngine

        protected boolean m_StartLocalEngine
        whether to start the local scripting engine.
      • m_Connection

        protected Connection m_Connection
        the connection to use.
      • m_Commands

        protected RemoteCommand[] m_Commands
        the commands to execute.
      • m_TimeOut

        protected int m_TimeOut
        the timeout in msec to wait for commands to finish.
    • Constructor Detail

      • CommandRunner

        public CommandRunner()
    • Method Detail

      • setStartLocalEngine

        public void setStartLocalEngine​(boolean value)
        Sets whether to start a local scripting engine.
        Parameters:
        value - true if to start
      • getStartLocalEngine

        public boolean getStartLocalEngine()
        Returns whether to start a local scripting engine.
        Returns:
        true if to start
      • startLocalEngineTipText

        public String startLocalEngineTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setEngine

        public void setEngine​(RemoteScriptingEngine value)
        Sets the scripting engine to use.
        Parameters:
        value - the engine
      • getEngine

        public RemoteScriptingEngine getEngine()
        Returns the scripting engine in use.
        Returns:
        the engine
      • engineTipText

        public String engineTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setConnection

        public void setConnection​(Connection value)
        Sets the connection to use.
        Parameters:
        value - the connection
      • getConnection

        public Connection getConnection()
        Returns the connection in use.
        Returns:
        the connection
      • connectionTipText

        public String connectionTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • commandProcessorTipText

        public String commandProcessorTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the gui
      • setCommands

        public void setCommands​(RemoteCommand[] value)
        Sets the commands to execute.
        Parameters:
        value - the commands
      • getCommands

        public RemoteCommand[] getCommands()
        Returns the commands to execute.
        Returns:
        the commands
      • commandsTipText

        public String commandsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setTimeOut

        public void setTimeOut​(int value)
        Sets the grace period to wait for commands to finish before shutting down.
        Parameters:
        value - the timeout in msec
      • getTimeOut

        public int getTimeOut()
        Returns the grace period to wait for commands to finish before shutting down.
        Returns:
        the timeout in msec
      • timeOutTipText

        public String timeOutTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • execute

        public String execute()
        Executes the commands.
        Returns:
        null if successful, otherwise error message
      • forName

        public static CommandRunner forName​(String classname,
                                            String[] options)
        Instantiates the flow with the given options.
        Parameters:
        classname - the classname of the flow to instantiate
        options - the options for the flow
        Returns:
        the instantiated flow or null if an error occurred
      • forCommandLine

        public static CommandRunner forCommandLine​(String cmdline)
        Instantiates the flow from the given commandline (i.e., classname and optional options).
        Parameters:
        cmdline - the classname (and optional options) of the flow to instantiate
        Returns:
        the instantiated flow or null if an error occurred
      • runCommands

        public static void runCommands​(Class env,
                                       Class runner,
                                       String[] args)
        Runs the flow from commandline.
        Parameters:
        env - the environment class to use
        runner - the flow class to execute
        args - the commandline arguments, use -help to display all
      • main

        public static void main​(String[] args)
        Runs the flow with the given options.
        Parameters:
        args - the options to use