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 boolean
m_Blocking
whether to use blocking or async mode.protected com.github.fracpete.processoutput4j.output.StreamingProcessOutput
m_ProcessOutput
for 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 void
addStdErr(String line)
Adds the line received on stderr from the command.void
addStdOut(String line)
Adds the line received on stdout from the command.String
blockingTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.protected Object
doAsyncExecute()
Executes the command.protected Object
doBlockingExecute()
Executes the command.boolean
getBlocking()
Returns whether to execute in blocking or async fashion.protected boolean
getDefaultBlocking()
Returns the default value for blocking mode.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.boolean
isFinished()
Returns whether the command finished.boolean
isUsingBlocking()
Whether the command is used in a blocking or async fashion.void
setBlocking(boolean value)
Sets whether to execute in blocking or async fashion.void
stopExecution()
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:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in 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:
setBlocking
in interfaceAsyncCapableExternalCommand
- Parameters:
value
- true for blocking
-
getBlocking
public boolean getBlocking()
Returns whether to execute in blocking or async fashion.- Specified by:
getBlocking
in interfaceAsyncCapableExternalCommand
- Returns:
- true for blocking
-
blockingTipText
public String blockingTipText()
Returns the tip text for this property.- Specified by:
blockingTipText
in 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:
addStdOut
in interfaceAsyncCapableExternalCommand
- Parameters:
line
- the line to add
-
addStdErr
public void addStdErr(String line)
Adds the line received on stderr from the command.- Specified by:
addStdErr
in interfaceAsyncCapableExternalCommand
- Parameters:
line
- the line to add
-
isUsingBlocking
public boolean isUsingBlocking()
Whether the command is used in a blocking or async fashion.- Specified by:
isUsingBlocking
in 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:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractExternalCommand
- Returns:
- null if no info available, otherwise short string
-
doAsyncExecute
protected Object doAsyncExecute()
Executes the command.- Overrides:
doAsyncExecute
in classAbstractExternalCommand
- Returns:
- the result of the command, either a CommandResult or a String object (= error message)
-
doBlockingExecute
protected Object doBlockingExecute()
Executes the command.- Overrides:
doBlockingExecute
in 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:
isFinished
in interfaceExternalCommand
- Overrides:
isFinished
in classAbstractExternalCommand
- Returns:
- true if finished
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceStoppable
- Overrides:
stopExecution
in classAbstractExternalCommand
-
-