Package com.sshtools.common.command
Class AbstractExecutableCommand
java.lang.Object
com.sshtools.common.command.AbstractExecutableCommand
- All Implemented Interfaces:
ExecutableCommand,Component
- Direct Known Subclasses:
NativeExecutableCommand,ScpCommand
This class can be extended to provide a single executable command. Commands
are configured in the
com.maverick.sshd.ConfigurationContext and they
make use of the input/output streams provided to communicate with the client.- Author:
- Lee David Painter
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.sshtools.common.command.ExecutableCommand
ExecutableCommand.ExecutableCommandFactory<T extends ExecutableCommand> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SessionChannelServerThe session channel instance on which this command is being executedFields inherited from interface com.sshtools.common.command.ExecutableCommand
STILL_ACTIVE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanallocatePseudoTerminal(String term, int cols, int rows, int width, int height, byte[] modes) abstract booleancreateProcess(String[] args, Map<String, String> environment) Create the process but wait for theonStart()method before performing any IO.abstract intGet the exit code for this process.Get the STDIN InputStream for this process.Get the STDOUT OutputStream for this process.Get the STDERR OutputStream for this process.voidinit(SessionChannelServer session) Initialize the command.abstract voidkill()Kill the command.abstract voidonStart()Called once the command has been started.voidstart()Start the command.
-
Field Details
-
session
The session channel instance on which this command is being executed
-
-
Constructor Details
-
AbstractExecutableCommand
public AbstractExecutableCommand()
-
-
Method Details
-
init
Initialize the command. This can be overridden but always call this super method with the command's session.- Specified by:
initin interfaceExecutableCommand- Parameters:
session-
-
getSession
- Specified by:
getSessionin interfaceExecutableCommand
-
createProcess
Create the process but wait for theonStart()method before performing any IO.- Specified by:
createProcessin interfaceExecutableCommand- Parameters:
cmd-environment-- Returns:
- boolean
-
start
public void start()Start the command.- Specified by:
startin interfaceExecutableCommand
-
onStart
public abstract void onStart()Called once the command has been started. Operations within this method SHOULD NOT block as this will cause the connection to lockup.- Specified by:
onStartin interfaceExecutableCommand
-
kill
public abstract void kill()Kill the command.- Specified by:
killin interfaceExecutableCommand
-
getExitCode
public abstract int getExitCode()Get the exit code for this process. If the process has not completed returnExecutableCommand.STILL_ACTIVE.- Specified by:
getExitCodein interfaceExecutableCommand- Returns:
- int
-
getOutputStream
Get the STDOUT OutputStream for this process.- Specified by:
getOutputStreamin interfaceExecutableCommand- Returns:
- OutputStream
-
getStderrOutputStream
Get the STDERR OutputStream for this process.- Specified by:
getStderrOutputStreamin interfaceExecutableCommand- Returns:
- OutputStream
-
getInputStream
Get the STDIN InputStream for this process.- Specified by:
getInputStreamin interfaceExecutableCommand- Returns:
- InputStream
-
allocatePseudoTerminal
public boolean allocatePseudoTerminal(String term, int cols, int rows, int width, int height, byte[] modes) - Specified by:
allocatePseudoTerminalin interfaceExecutableCommand
-