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 class
AbstractSystemCommandExecuterImpl.PlatformDependentCommand
Platform dependent command
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractSystemCommandExecuterImpl(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.ProcessBuilder
createProcessBuilder(AbstractSystemCommandExecuterImpl.PlatformDependentCommand platformDependentCommand)
Create a process builderprotected abstract java.util.List<java.lang.String>
getShellCommand(IProcessEnvironment processEnvironment, ISystemCommand systemCommand)
Get the shell commandprotected AbstractSystemCommandExecuterImpl.PlatformDependentCommand
preparePlatformDependentCommandList(IProcessEnvironment processEnvironment, ISystemCommand systemCommand)
Prepare platform dependent command list.IAsynchronousProcess
runAsynchronous()
Start a new command asynchronous process.IProcess
runSynchronous()
Start a new command synchronous process.IProcess
runSynchronous(int numberOfSecondsToWait)
Start a new command synchronous process.protected void
validateProcessEnvironment(IProcessEnvironment processEnvironment)
Validate the process environmentprotected void
validateSystemCommand(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:ISystemCommandExecuter
Start a new command synchronous process. You will get back the terminated process.- Specified by:
runSynchronous
in interfaceISystemCommandExecuter
- Returns:
- the terminated process
- See Also:
ISystemCommandExecuter.runSynchronous()
-
runSynchronous
public IProcess runSynchronous(int numberOfSecondsToWait)
Description copied from interface:ISystemCommandExecuter
Start 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:
runSynchronous
in 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:ISystemCommandExecuter
Start a new command asynchronous process. You will get back the started process.- Specified by:
runAsynchronous
in 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
-
-