public abstract class AbstractCommandSupport extends AbstractLoggingBean implements Command, java.lang.Runnable, ExecutorServiceCarrier, SessionAware, SessionHolder<ServerSession>, ServerSessionHolder
Command
executionsModifier and Type | Field and Description |
---|---|
private ExitCallback |
callback |
protected boolean |
cbCalled |
private java.util.concurrent.Future<?> |
cmdFuture |
protected java.lang.Thread |
cmdRunner |
private java.lang.String |
command |
private Environment |
environment |
private java.io.OutputStream |
err |
protected CloseableExecutorService |
executorService |
private java.io.InputStream |
in |
private java.io.OutputStream |
out |
private ServerSession |
serverSession |
log
Modifier | Constructor and Description |
---|---|
protected |
AbstractCommandSupport(java.lang.String command,
CloseableExecutorService executorService) |
Modifier and Type | Method and Description |
---|---|
void |
destroy(ChannelSession channel)
This method is called by the SSH server to destroy the command because the client has disconnected somehow.
|
java.lang.String |
getCommand() |
Environment |
getEnvironment() |
java.io.OutputStream |
getErrorStream() |
CloseableExecutorService |
getExecutorService() |
ExitCallback |
getExitCallback() |
java.io.InputStream |
getInputStream() |
java.io.OutputStream |
getOutputStream() |
ServerSession |
getServerSession() |
ServerSession |
getSession() |
protected java.util.concurrent.Future<?> |
getStartedCommandFuture() |
protected void |
onExit(int exitValue) |
protected void |
onExit(int exitValue,
java.lang.String exitMessage) |
void |
setErrorStream(java.io.OutputStream err)
Set the error stream that can be used by the shell to write its errors.
|
void |
setExitCallback(ExitCallback callback)
Set the callback that the shell has to call when it is closed.
|
void |
setInputStream(java.io.InputStream in)
Set the input stream that can be used by the shell to read input.
|
void |
setOutputStream(java.io.OutputStream out)
Set the output stream that can be used by the shell to write its output.
|
void |
setSession(ServerSession session) |
void |
start(ChannelSession channel,
Environment env)
Starts the command execution.
|
java.lang.String |
toString() |
getSimplifiedLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getSessionContext
protected volatile java.lang.Thread cmdRunner
protected CloseableExecutorService executorService
protected boolean cbCalled
private final java.lang.String command
private java.io.InputStream in
private java.io.OutputStream out
private java.io.OutputStream err
private ExitCallback callback
private Environment environment
private java.util.concurrent.Future<?> cmdFuture
private ServerSession serverSession
protected AbstractCommandSupport(java.lang.String command, CloseableExecutorService executorService)
public java.lang.String getCommand()
public ServerSession getSession()
getSession
in interface SessionHolder<ServerSession>
public ServerSession getServerSession()
getServerSession
in interface ServerSessionHolder
ServerSession
usedpublic void setSession(ServerSession session)
setSession
in interface SessionAware
session
- The ServerSession
in which this shell will be executed.public CloseableExecutorService getExecutorService()
getExecutorService
in interface ExecutorServiceCarrier
CloseableExecutorService
to usepublic java.io.InputStream getInputStream()
public void setInputStream(java.io.InputStream in)
Command
setInputStream
in interface Command
in
- The InputStream
used by the shell to read input.public java.io.OutputStream getOutputStream()
public void setOutputStream(java.io.OutputStream out)
Command
setOutputStream
in interface Command
out
- The OutputStream
used by the shell to write its outputpublic java.io.OutputStream getErrorStream()
public void setErrorStream(java.io.OutputStream err)
Command
setErrorStream
in interface Command
err
- The OutputStream
used by the shell to write its errorspublic ExitCallback getExitCallback()
public void setExitCallback(ExitCallback callback)
Command
setExitCallback
in interface Command
callback
- The ExitCallback
to call when shell is closedpublic Environment getEnvironment()
protected java.util.concurrent.Future<?> getStartedCommandFuture()
public void start(ChannelSession channel, Environment env) throws java.io.IOException
CommandLifecycle
Runnable
, and this method should spawn a new thread like:
Thread(this).start();
start
in interface CommandLifecycle
channel
- The ChannelSession
through which the command has been receivedenv
- The Environment
java.io.IOException
- If failed to startpublic void destroy(ChannelSession channel) throws java.lang.Exception
CommandLifecycle
destroy
in interface CommandLifecycle
channel
- The ChannelSession
through which the command has been receivedjava.lang.Exception
- if failed to destroyprotected void onExit(int exitValue)
protected void onExit(int exitValue, java.lang.String exitMessage)
public java.lang.String toString()
toString
in class java.lang.Object