Class AbstractSystemCommandExecuterImpl
- java.lang.Object
-
- com.github.toolarium.system.command.impl.AbstractSystemCommandExecuterImpl
-
- All Implemented Interfaces:
ISystemCommandExecuter
- Direct Known Subclasses:
UnixSystemCommandExecuterImpl,WindowsSystemCommandExecuterImpl
public abstract class AbstractSystemCommandExecuterImpl extends java.lang.Object implements ISystemCommandExecuter
Abstract base class for system command execution
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classAbstractSystemCommandExecuterImpl.PlatformDependentCommandPlatform dependent command
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSystemCommandExecuterImpl(IProcessEnvironment processEnvironment, ISystemCommand systemCommand)Constructor for AbstractSystemCommandExecuterImpl
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.ProcessBuildercreateProcessBuilder(AbstractSystemCommandExecuterImpl.PlatformDependentCommand platformDependentCommand)Create a process builderprotected abstract java.util.List<java.lang.String>getShellCommand(IProcessEnvironment processEnvironment, ISystemCommand systemCommand)Get the shell commandprotected AbstractSystemCommandExecuterImpl.PlatformDependentCommandpreparePlatformDependentCommandList(IProcessEnvironment processEnvironment, ISystemCommand systemCommand)Prepare platform dependent command list.IAsynchronousProcessrunAsynchronous()Start a new command asynchronous process.IProcessrunSynchronous()Start a new command synchronous process.IProcessrunSynchronous(int numberOfSecondsToWait)Start a new command synchronous process.protected voidvalidateProcessEnvironment(IProcessEnvironment processEnvironment)Validate the process environmentprotected voidvalidateSystemCommand(ISystemCommand systemCommand)Validate the command list
-
-
-
Constructor Detail
-
AbstractSystemCommandExecuterImpl
protected AbstractSystemCommandExecuterImpl(IProcessEnvironment processEnvironment, ISystemCommand systemCommand)
Constructor for AbstractSystemCommandExecuterImpl- Parameters:
processEnvironment- the process environmentsystemCommand- the system command
-
-
Method Detail
-
runSynchronous
public IProcess 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 IProcess 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)
-
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 process
- See Also:
ISystemCommandExecuter.runAsynchronous()
-
validateSystemCommand
protected void validateSystemCommand(ISystemCommand systemCommand)
Validate the command list- Parameters:
systemCommand- the system command- Throws:
java.lang.IllegalArgumentException- In case of a invalid command list
-
validateProcessEnvironment
protected void validateProcessEnvironment(IProcessEnvironment processEnvironment)
Validate the process environment- Parameters:
processEnvironment- the process environment
-
createProcessBuilder
protected java.lang.ProcessBuilder createProcessBuilder(AbstractSystemCommandExecuterImpl.PlatformDependentCommand platformDependentCommand)
Create a process builder- Parameters:
platformDependentCommand- platform dependent command- Returns:
- the process builder
-
preparePlatformDependentCommandList
protected AbstractSystemCommandExecuterImpl.PlatformDependentCommand preparePlatformDependentCommandList(IProcessEnvironment processEnvironment, ISystemCommand systemCommand)
Prepare platform dependent command list.- Parameters:
processEnvironment- the process environmentsystemCommand- the system command- Returns:
- the platform dependent command list
-
getShellCommand
protected abstract java.util.List<java.lang.String> getShellCommand(IProcessEnvironment processEnvironment, ISystemCommand systemCommand)
Get the shell command- Parameters:
processEnvironment- the process environmentsystemCommand- the system command- Returns:
- the shell command
-
-