Package adams.core.command
Class AbstractAsyncCapableExternalCommand
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.core.command.AbstractExternalCommand
-
- adams.core.command.AbstractAsyncCapableExternalCommand
-
- All Implemented Interfaces:
CleanUpHandler,AsyncCapableExternalCommand,ExternalCommand,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,QuickInfoSupporter,SizeOfHandler,Stoppable,StoppableWithFeedback,FlowContextHandler,Serializable
- Direct Known Subclasses:
AbstractAsyncCapableExternalCommandWithOptions
public abstract class AbstractAsyncCapableExternalCommand extends AbstractExternalCommand implements AsyncCapableExternalCommand
Ancestor for external commands that can be run in blocking or async mode.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_Blockingwhether to use blocking or async mode.protected com.github.fracpete.processoutput4j.output.StreamingProcessOutputm_ProcessOutputfor capturing the command output.-
Fields inherited from class adams.core.command.AbstractExternalCommand
m_Executed, m_FlowContext, m_LastCommand, m_Output, m_OutputFormatter, m_OutputType, m_Running, m_StdErrProcessor, m_StdOutProcessor, m_Stopped
-
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 AbstractAsyncCapableExternalCommand()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddStdErr(String line)Adds the line received on stderr from the command.voidaddStdOut(String line)Adds the line received on stdout from the command.StringblockingTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected ObjectdoAsyncExecute()Executes the command.protected ObjectdoBlockingExecute()Executes the command.booleangetBlocking()Returns whether to execute in blocking or async fashion.protected booleangetDefaultBlocking()Returns the default value for blocking mode.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.booleanisFinished()Returns whether the command finished.booleanisUsingBlocking()Whether the command is used in a blocking or async fashion.voidsetBlocking(boolean value)Sets whether to execute in blocking or async fashion.voidstopExecution()Stops the execution.-
Methods inherited from class adams.core.command.AbstractExternalCommand
addFormattedOutput, buildCommand, check, cleanUp, commandResultToError, execute, generates, getDefaultOutputFormatter, getDefaultOutputType, getDefaultStdErrProcessor, getDefaultStdOutProcessor, getFlowContext, getLastCommand, getOutputFormatter, getOutputType, getStdErrProcessor, getStdOutProcessor, hasLastCommand, hasOutput, initialize, isExecuted, isRunning, isStopped, log, log, log, output, outputFormatterTipText, outputTypeTipText, reset, setFlowContext, setOutputFormatter, setOutputType, setStdErrProcessor, setStdOutProcessor, stdErrProcessorTipText, stdOutProcessorTipText
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, 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.Destroyable
destroy
-
Methods inherited from interface adams.core.command.ExternalCommand
addFormattedOutput, cleanUp, execute, generates, getLastCommand, getOutputFormatter, getOutputType, getStdErrProcessor, getStdOutProcessor, hasLastCommand, hasOutput, isExecuted, isRunning, output, outputFormatterTipText, outputTypeTipText, setOutputFormatter, setOutputType, setStdErrProcessor, setStdOutProcessor, stdErrProcessorTipText, stdOutProcessorTipText
-
Methods inherited from interface adams.flow.core.FlowContextHandler
getFlowContext, setFlowContext
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
Methods inherited from interface adams.core.StoppableWithFeedback
isStopped
-
-
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractExternalCommand
-
getDefaultBlocking
protected boolean getDefaultBlocking()
Returns the default value for blocking mode.- Returns:
- thed efault
-
setBlocking
public void setBlocking(boolean value)
Sets whether to execute in blocking or async fashion.- Specified by:
setBlockingin interfaceAsyncCapableExternalCommand- Parameters:
value- true for blocking
-
getBlocking
public boolean getBlocking()
Returns whether to execute in blocking or async fashion.- Specified by:
getBlockingin interfaceAsyncCapableExternalCommand- Returns:
- true for blocking
-
blockingTipText
public String blockingTipText()
Returns the tip text for this property.- Specified by:
blockingTipTextin interfaceAsyncCapableExternalCommand- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
addStdOut
public void addStdOut(String line)
Adds the line received on stdout from the command.- Specified by:
addStdOutin interfaceAsyncCapableExternalCommand- Parameters:
line- the line to add
-
addStdErr
public void addStdErr(String line)
Adds the line received on stderr from the command.- Specified by:
addStdErrin interfaceAsyncCapableExternalCommand- Parameters:
line- the line to add
-
isUsingBlocking
public boolean isUsingBlocking()
Whether the command is used in a blocking or async fashion.- Specified by:
isUsingBlockingin interfaceExternalCommand- Returns:
- true if blocking, false if async
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfoin interfaceQuickInfoSupporter- Overrides:
getQuickInfoin classAbstractExternalCommand- Returns:
- null if no info available, otherwise short string
-
doAsyncExecute
protected Object doAsyncExecute()
Executes the command.- Overrides:
doAsyncExecutein classAbstractExternalCommand- Returns:
- the result of the command, either a CommandResult or a String object (= error message)
-
doBlockingExecute
protected Object doBlockingExecute()
Executes the command.- Overrides:
doBlockingExecutein classAbstractExternalCommand- Returns:
- the result of the command, either a CommandResult or a String object (= error message)
-
isFinished
public boolean isFinished()
Returns whether the command finished.- Specified by:
isFinishedin interfaceExternalCommand- Overrides:
isFinishedin classAbstractExternalCommand- Returns:
- true if finished
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceStoppable- Overrides:
stopExecutionin classAbstractExternalCommand
-
-