Class AbstractSystemCommandExecuterImpl
- java.lang.Object
-
- com.github.toolarium.system.command.executer.impl.AbstractSystemCommandExecuterImpl
-
- All Implemented Interfaces:
ISystemCommandExecuter,ISystemCommandExecuterPlatformSupport
- Direct Known Subclasses:
UnixSystemCommandExecuterImpl,WindowsSystemCommandExecuterImpl
public abstract class AbstractSystemCommandExecuterImpl extends java.lang.Object implements ISystemCommandExecuter, ISystemCommandExecuterPlatformSupport
Abstract base class for system command execution
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_POLL_TIMEOUTThe default poll timeout
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSystemCommandExecuterImpl(ISystemCommandGroupList systemCommandGroupList)Constructor for AbstractSystemCommandExecuterImpl
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ISystemCommandGroupListgetSystemCommandGroupList()Get the system command group listprotected java.lang.StringprepareDuration(IAsynchronousProcess process)Prepare durationIAsynchronousProcessrunAsynchronous()Start a new command asynchronous process.IAsynchronousProcessrunAsynchronous(IProcessInputStream processInputStream, IProcessOutputStream processOut, IProcessOutputStream processErr)Start a new command asynchronous process.IAsynchronousProcessrunAsynchronous(IProcessInputStream processInputStream, IProcessOutputStream processOut, IProcessOutputStream processErr, long pollTimeout)Start a new command asynchronous process.IAsynchronousProcessrunAsynchronous(IProcessOutputStream processOutAndErr)Start a new command asynchronous process.IAsynchronousProcessrunAsynchronous(IProcessOutputStream processOut, IProcessOutputStream processErr)Start a new command asynchronous process.ISynchronousProcessrunSynchronous()Start a new command synchronous process.ISynchronousProcessrunSynchronous(int numberOfSecondsToWait)Start a new command synchronous process.ISynchronousProcessrunSynchronous(IProcessInputStream processInputStream, int numberOfSecondsToWait)Start a new command asynchronous process.voidwriteToFile(java.nio.file.Path file, java.lang.String content)Write content to the temporary file-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.toolarium.system.command.executer.ISystemCommandExecuterPlatformSupport
getCommandOnErrorEnd, getCommandOnErrorStart, getCommandOnSuccessEnd, getCommandOnSuccessStart, getEndOfLine, getEnvironmentAssignCommand, getEnvironmentAssignCommandEnd, getEnvironmentChangeDirectoryCommand, getEnvironmentSetCommand, getEnvironmentUnsetCommand, getNotExistEnvironmentVariableCommand, getScriptFileComment, getScriptFileExtension, getScriptFileFooter, getScriptFileHeader, getShellEndCommand, getShellStartCommand, getSudo
-
-
-
-
Field Detail
-
DEFAULT_POLL_TIMEOUT
public static final int DEFAULT_POLL_TIMEOUT
The default poll timeout- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractSystemCommandExecuterImpl
protected AbstractSystemCommandExecuterImpl(ISystemCommandGroupList systemCommandGroupList)
Constructor for AbstractSystemCommandExecuterImpl- Parameters:
systemCommandGroupList- the system command group list- Throws:
java.lang.IllegalArgumentException- In case of an invalid system command list
-
-
Method Detail
-
runSynchronous
public ISynchronousProcess runSynchronous()
Description copied from interface:ISystemCommandExecuterStart a new command synchronous process. You will get back the terminated process.- Specified by:
runSynchronousin interfaceISystemCommandExecuter- Returns:
- the terminated process
- See Also:
ISystemCommandExecuter.runSynchronous()
-
runSynchronous
public ISynchronousProcess runSynchronous(int numberOfSecondsToWait)
Description copied from interface:ISystemCommandExecuterStart a new command synchronous process. You will get back the terminated process. In case it could not be finished in the given time it will be destroyed.- Specified by:
runSynchronousin interfaceISystemCommandExecuter- Parameters:
numberOfSecondsToWait- the number of seconds to wait. If the value less or equal 0, it waits until it is executed- Returns:
- the process
- See Also:
ISystemCommandExecuter.runSynchronous(int)
-
runSynchronous
public ISynchronousProcess runSynchronous(IProcessInputStream processInputStream, int numberOfSecondsToWait)
Description copied from interface:ISystemCommandExecuterStart a new command asynchronous process. You will get back the started process.- Specified by:
runSynchronousin interfaceISystemCommandExecuter- Parameters:
processInputStream- the process input streamnumberOfSecondsToWait- the number of seconds to wait. If the value less or equal 0, it waits until it is executed- Returns:
- the asynchronous process which is already started
- See Also:
ISystemCommandExecuter.runSynchronous(com.github.toolarium.system.command.process.stream.IProcessInputStream, int)
-
runAsynchronous
public IAsynchronousProcess runAsynchronous()
Description copied from interface:ISystemCommandExecuterStart a new command asynchronous process. You will get back the started process.- Specified by:
runAsynchronousin interfaceISystemCommandExecuter- Returns:
- the asynchronous process which is already started
- See Also:
ISystemCommandExecuter.runAsynchronous()
-
runAsynchronous
public IAsynchronousProcess runAsynchronous(IProcessOutputStream processOutAndErr)
Description copied from interface:ISystemCommandExecuterStart a new command asynchronous process. You will get back the started process.- Specified by:
runAsynchronousin interfaceISystemCommandExecuter- Parameters:
processOutAndErr- the process output and error stream- Returns:
- the asynchronous process which is already started
- See Also:
ISystemCommandExecuter.runAsynchronous(com.github.toolarium.system.command.process.stream.IProcessOutputStream)
-
runAsynchronous
public IAsynchronousProcess runAsynchronous(IProcessOutputStream processOut, IProcessOutputStream processErr)
Description copied from interface:ISystemCommandExecuterStart a new command asynchronous process. You will get back the started process.- Specified by:
runAsynchronousin interfaceISystemCommandExecuter- Parameters:
processOut- the process output streamprocessErr- the process error stream- Returns:
- the asynchronous process which is already started
- See Also:
ISystemCommandExecuter.runAsynchronous(com.github.toolarium.system.command.process.stream.IProcessOutputStream, com.github.toolarium.system.command.process.stream.IProcessOutputStream)
-
runAsynchronous
public IAsynchronousProcess runAsynchronous(IProcessInputStream processInputStream, IProcessOutputStream processOut, IProcessOutputStream processErr)
Description copied from interface:ISystemCommandExecuterStart a new command asynchronous process. You will get back the started process.- Specified by:
runAsynchronousin interfaceISystemCommandExecuter- Parameters:
processInputStream- the process input streamprocessOut- the process output streamprocessErr- the process error stream- Returns:
- the asynchronous process which is already started
- See Also:
ISystemCommandExecuter.runAsynchronous(com.github.toolarium.system.command.process.stream.IProcessInputStream, com.github.toolarium.system.command.process.stream.IProcessOutputStream, com.github.toolarium.system.command.process.stream.IProcessOutputStream)
-
runAsynchronous
public IAsynchronousProcess runAsynchronous(IProcessInputStream processInputStream, IProcessOutputStream processOut, IProcessOutputStream processErr, long pollTimeout)
Description copied from interface:ISystemCommandExecuterStart a new command asynchronous process. You will get back the started process.- Specified by:
runAsynchronousin interfaceISystemCommandExecuter- Parameters:
processInputStream- the process input streamprocessOut- the process output streamprocessErr- the process error streampollTimeout- the poll timeout to handle the output streams- Returns:
- the asynchronous process which is already started
- See Also:
ISystemCommandExecuter.runAsynchronous(com.github.toolarium.system.command.process.stream.IProcessInputStream, com.github.toolarium.system.command.process.stream.IProcessOutputStream, com.github.toolarium.system.command.process.stream.IProcessOutputStream, long)
-
writeToFile
public void writeToFile(java.nio.file.Path file, java.lang.String content) throws java.io.IOExceptionDescription copied from interface:ISystemCommandExecuterPlatformSupportWrite content to the temporary file- Specified by:
writeToFilein interfaceISystemCommandExecuterPlatformSupport- Parameters:
file- the current temporary filecontent- the content to write- Throws:
java.io.IOException- In case of write issues- See Also:
ISystemCommandExecuterPlatformSupport.writeToFile(java.nio.file.Path, java.lang.String)
-
prepareDuration
protected java.lang.String prepareDuration(IAsynchronousProcess process)
Prepare duration- Parameters:
process- the process- Returns:
- the duration
-
getSystemCommandGroupList
protected ISystemCommandGroupList getSystemCommandGroupList()
Get the system command group list- Returns:
- the system command group list
-
-