Package adams.scripting
Class CommandRunner
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.scripting.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 Summary
Fields Modifier and Type Field Description protected RemoteCommandProcessorm_CommandProcessorthe command processor.protected RemoteCommand[]m_Commandsthe commands to execute.protected Connectionm_Connectionthe connection to use.protected RemoteScriptingEnginem_Enginethe scripting engine to use.protected booleanm_StartLocalEnginewhether to start the local scripting engine.protected intm_TimeOutthe timeout in msec to wait for commands to finish.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description CommandRunner()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcommandProcessorTipText()Returns the tip text for this property.StringcommandsTipText()Returns the tip text for this property.StringconnectionTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.StringengineTipText()Returns the tip text for this property.Stringexecute()Executes the commands.static CommandRunnerforCommandLine(String cmdline)Instantiates the flow from the given commandline (i.e., classname and optional options).static CommandRunnerforName(String classname, String[] options)Instantiates the flow with the given options.RemoteCommandProcessorgetCommandProcessor()Returns the command processor in use.RemoteCommand[]getCommands()Returns the commands to execute.ConnectiongetConnection()Returns the connection in use.RemoteScriptingEnginegetEngine()Returns the scripting engine in use.booleangetStartLocalEngine()Returns whether to start a local scripting engine.intgetTimeOut()Returns the grace period to wait for commands to finish before shutting down.StringglobalInfo()Returns a string describing the object.static voidmain(String[] args)Runs the flow with the given options.static voidrunCommands(Class env, Class runner, String[] args)Runs the flow from commandline.voidsetCommandProcessor(RemoteCommandProcessor value)Sets the command processor to use.voidsetCommands(RemoteCommand[] value)Sets the commands to execute.voidsetConnection(Connection value)Sets the connection to use.voidsetEngine(RemoteScriptingEngine value)Sets the scripting engine to use.voidsetStartLocalEngine(boolean value)Sets whether to start a local scripting engine.voidsetTimeOut(int value)Sets the grace period to wait for commands to finish before shutting down.StringstartLocalEngineTipText()Returns the tip text for this property.StringtimeOutTipText()Returns the tip text for this property.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_StartLocalEngine
protected boolean m_StartLocalEngine
whether to start the local scripting engine.
-
m_Engine
protected RemoteScriptingEngine m_Engine
the scripting engine to use.
-
m_Connection
protected Connection m_Connection
the connection to use.
-
m_CommandProcessor
protected RemoteCommandProcessor m_CommandProcessor
the command processor.
-
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.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
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.
-
setCommandProcessor
public void setCommandProcessor(RemoteCommandProcessor value)
Sets the command processor to use.- Specified by:
setCommandProcessorin interfaceRemoteCommandProcessorHandler- Parameters:
value- the processor
-
getCommandProcessor
public RemoteCommandProcessor getCommandProcessor()
Returns the command processor in use.- Specified by:
getCommandProcessorin interfaceRemoteCommandProcessorHandler- Returns:
- the processor
-
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 instantiateoptions- 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 userunner- the flow class to executeargs- 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
-
-