public class InvertedShellWrapper extends AbstractLoggingBean implements Command, ServerSessionAware
InvertedShell as a Command. This is useful when
using external processes. When starting the shell, this wrapper will also create a thread used to pump the streams
and also to check if the shell is alive.log| Constructor and Description |
|---|
InvertedShellWrapper(InvertedShell shell)
Auto-allocates an
Executor in order to create the streams pump thread and uses the default
CoreModuleProperties.BUFFER_SIZE |
InvertedShellWrapper(InvertedShell shell,
Executor executor,
boolean shutdownExecutor,
int bufferSize) |
InvertedShellWrapper(InvertedShell shell,
int bufferSize)
Auto-allocates an
Executor in order to create the streams pump thread |
| 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.
|
protected boolean |
pumpStream(InputStream in,
OutputStream out,
byte[] buffer) |
protected void |
pumpStreams() |
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() |
public InvertedShellWrapper(InvertedShell shell)
Executor in order to create the streams pump thread and uses the default
CoreModuleProperties.BUFFER_SIZEshell - The InvertedShellInvertedShellWrapper(InvertedShell, int)public InvertedShellWrapper(InvertedShell shell, int bufferSize)
Executor in order to create the streams pump threadshell - The InvertedShellbufferSize - Buffer size to use - must be above min. size (Byte.SIZE)InvertedShellWrapper(InvertedShell, Executor, boolean, int)public InvertedShellWrapper(InvertedShell shell, Executor executor, boolean shutdownExecutor, int bufferSize)
shell - The InvertedShellexecutor - The Executor to use in order to create the streams pump thread. If null
one is auto-allocated and shutdown when wrapper is destroy()-ed.shutdownExecutor - If true the executor is shut down when shell wrapper is destroy()-ed.
Ignored if executor service auto-allocatedbufferSize - Buffer size to use - must be above min. size (Byte.SIZE)public void setInputStream(InputStream in)
CommandDirectInputStreamAwaresetInputStream in interface CommandDirectInputStreamAwarein - The InputStream used by the shell to read input.public void setOutputStream(OutputStream out)
CommandDirectOutputStreamAwaresetOutputStream in interface CommandDirectOutputStreamAwareout - The OutputStream used by the shell to write its outputpublic void setErrorStream(OutputStream err)
CommandDirectErrorStreamAwaresetErrorStream in interface CommandDirectErrorStreamAwareerr - The OutputStream used by the shell to write its errorspublic void setExitCallback(ExitCallback callback)
CommandsetExitCallback in interface Commandcallback - The ExitCallback to call when shell is closedpublic void setSession(ServerSession session)
setSession in interface ServerSessionAwaresession - The ServerSession in which this shell will be executed.public void start(ChannelSession channel, Environment env) throws IOException
CommandLifecycleRunnable, and this method should spawn a new thread like:
Thread(this).start();
start in interface CommandLifecyclechannel - The ChannelSession through which the command has been receivedenv - The EnvironmentIOException - If failed to startpublic void destroy(ChannelSession channel) throws Exception
CommandLifecycledestroy in interface CommandLifecyclechannel - The ChannelSession through which the command has been receivedException - if failed to destroyprotected void pumpStreams()
protected boolean pumpStream(InputStream in, OutputStream out, byte[] buffer) throws IOException
IOExceptionCopyright © 2008–2021 The Apache Software Foundation. All rights reserved.