public abstract class AbstractCommandSupport extends AbstractLoggingBean implements Command, Runnable, ExecutorServiceCarrier, SessionAware, SessionHolder<Session>, ServerSessionHolder
Command
executionsModifier and Type | Field and Description |
---|---|
protected ExitCallback |
callback |
protected boolean |
cbCalled |
protected Future<?> |
cmdFuture |
protected Thread |
cmdRunner |
protected String |
command |
protected Environment |
environment |
protected OutputStream |
err |
protected ExecutorService |
executorService |
protected InputStream |
in |
protected OutputStream |
out |
protected ServerSession |
serverSession |
protected boolean |
shutdownOnExit |
log
Modifier | Constructor and Description |
---|---|
protected |
AbstractCommandSupport(String command,
ExecutorService executorService,
boolean shutdownOnExit) |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
This method is called by the SSH server to destroy the command because
the client has disconnected somehow.
|
String |
getCommand() |
Environment |
getEnvironment() |
OutputStream |
getErrorStream() |
ExecutorService |
getExecutorService() |
ExitCallback |
getExitCallback() |
InputStream |
getInputStream() |
OutputStream |
getOutputStream() |
ServerSession |
getServerSession() |
Session |
getSession() |
protected Future<?> |
getStartedCommandFuture() |
boolean |
isShutdownOnExit() |
protected void |
onExit(int exitValue) |
protected void |
onExit(int exitValue,
String exitMessage) |
void |
setErrorStream(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(InputStream in)
Set the input stream that can be used by the shell to read input.
|
void |
setOutputStream(OutputStream out)
Set the output stream that can be used by the shell to write its output.
|
void |
setSession(ServerSession session) |
void |
start(Environment env)
Starts the command execution.
|
String |
toString() |
getSimplifiedLogger
protected final String command
protected InputStream in
protected OutputStream out
protected OutputStream err
protected ExitCallback callback
protected Environment environment
protected Future<?> cmdFuture
protected Thread cmdRunner
protected ExecutorService executorService
protected boolean shutdownOnExit
protected boolean cbCalled
protected ServerSession serverSession
protected AbstractCommandSupport(String command, ExecutorService executorService, boolean shutdownOnExit)
public String getCommand()
public Session getSession()
getSession
in interface SessionHolder<Session>
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 ExecutorService getExecutorService()
getExecutorService
in interface ExecutorServiceCarrier
ExecutorService
to usepublic boolean isShutdownOnExit()
isShutdownOnExit
in interface ExecutorServiceCarrier
true
then the ExecutorService.shutdownNow()
will be called (unless it is an internally allocated service which is always
closed)public InputStream getInputStream()
public void setInputStream(InputStream in)
Command
setInputStream
in interface Command
in
- The InputStream
used by the shell to read input.public OutputStream getOutputStream()
public void setOutputStream(OutputStream out)
Command
setOutputStream
in interface Command
out
- The OutputStream
used by the shell to write its outputpublic OutputStream getErrorStream()
public void setErrorStream(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 Future<?> getStartedCommandFuture()
public void start(Environment env) throws IOException
CommandLifecycle
Runnable
,
and this method should spawn a new thread like:
Thread(this).start();
start
in interface CommandLifecycle
env
- The Environment
IOException
- If failed to startpublic void destroy()
CommandLifecycle
destroy
in interface CommandLifecycle
protected void onExit(int exitValue)
protected void onExit(int exitValue, String exitMessage)
Copyright © 2008–2019 The Apache Software Foundation. All rights reserved.