public abstract class AbstractCommandSupport extends AbstractLoggingBean implements Command, Runnable, ExecutorServiceCarrier, ServerSessionAware, SessionHolder<ServerSession>, ServerSessionHolder
Command
executionsModifier and Type | Field and Description |
---|---|
protected boolean |
cbCalled |
protected Thread |
cmdRunner |
protected CloseableExecutorService |
executorService |
log
Modifier | Constructor and Description |
---|---|
protected |
AbstractCommandSupport(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.
|
String |
getCommand() |
Environment |
getEnvironment() |
OutputStream |
getErrorStream() |
CloseableExecutorService |
getExecutorService() |
ExitCallback |
getExitCallback() |
InputStream |
getInputStream() |
OutputStream |
getOutputStream() |
ServerSession |
getServerSession() |
ServerSession |
getSession() |
protected Future<?> |
getStartedCommandFuture() |
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(ChannelSession channel,
Environment env)
Starts the command execution.
|
String |
toString() |
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getSessionContext
protected volatile Thread cmdRunner
protected CloseableExecutorService executorService
protected boolean cbCalled
protected AbstractCommandSupport(String command, CloseableExecutorService executorService)
public 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 ServerSessionAware
session
- The ServerSession
in which this shell will be executed.public CloseableExecutorService getExecutorService()
getExecutorService
in interface ExecutorServiceCarrier
CloseableExecutorService
to usepublic InputStream getInputStream()
public void setInputStream(InputStream in)
CommandDirectInputStreamAware
setInputStream
in interface CommandDirectInputStreamAware
in
- The InputStream
used by the shell to read input.public OutputStream getOutputStream()
public void setOutputStream(OutputStream out)
CommandDirectOutputStreamAware
setOutputStream
in interface CommandDirectOutputStreamAware
out
- The OutputStream
used by the shell to write its outputpublic OutputStream getErrorStream()
public void setErrorStream(OutputStream err)
CommandDirectErrorStreamAware
setErrorStream
in interface CommandDirectErrorStreamAware
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(ChannelSession channel, Environment env) throws 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
IOException
- If failed to startpublic void destroy(ChannelSession channel) throws Exception
CommandLifecycle
destroy
in interface CommandLifecycle
channel
- The ChannelSession
through which the command has been receivedException
- if failed to destroyprotected void onExit(int exitValue)
protected void onExit(int exitValue, String exitMessage)
Copyright © 2008–2024 The Apache Software Foundation. All rights reserved.