public class ScpCommand extends AbstractLoggingBean implements Command, Runnable, FileSystemAware, SessionAware, SessionHolder<Session>, ServerSessionHolder
| Modifier and Type | Field and Description |
|---|---|
protected ExitCallback |
callback |
protected OutputStream |
err |
protected IOException |
error |
protected ExecutorService |
executors |
protected FileSystem |
fileSystem |
protected InputStream |
in |
protected ScpTransferEventListener |
listener |
protected String |
name |
protected ScpFileOpener |
opener |
protected boolean |
optD |
protected boolean |
optF |
protected boolean |
optP |
protected boolean |
optR |
protected boolean |
optT |
protected OutputStream |
out |
protected String |
path |
protected Future<?> |
pendingFuture |
protected int |
receiveBufferSize |
protected int |
sendBufferSize |
protected ServerSession |
serverSession |
protected boolean |
shutdownExecutor |
log| Constructor and Description |
|---|
ScpCommand(String command,
ExecutorService executorService,
boolean shutdownOnExit,
int sendSize,
int receiveSize,
ScpFileOpener fileOpener,
ScpTransferEventListener eventListener) |
| 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.
|
ServerSession |
getServerSession() |
Session |
getSession() |
void |
run() |
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 |
setFileSystem(FileSystem fs)
Set the file system in which this shell will be executed.
|
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() |
protected void |
writeCommandResponseMessage(String command,
int exitValue,
String exitMessage) |
getSimplifiedLoggerprotected final String name
protected final int sendBufferSize
protected final int receiveBufferSize
protected final ScpFileOpener opener
protected boolean optR
protected boolean optT
protected boolean optF
protected boolean optD
protected boolean optP
protected FileSystem fileSystem
protected String path
protected InputStream in
protected OutputStream out
protected OutputStream err
protected ExitCallback callback
protected IOException error
protected ExecutorService executors
protected boolean shutdownExecutor
protected Future<?> pendingFuture
protected ScpTransferEventListener listener
protected ServerSession serverSession
public ScpCommand(String command, ExecutorService executorService, boolean shutdownOnExit, int sendSize, int receiveSize, ScpFileOpener fileOpener, ScpTransferEventListener eventListener)
command - The command to be executedexecutorService - An ExecutorService to be used when
start(Environment)-ing execution. If null an ad-hoc
single-threaded service is created and used.shutdownOnExit - If true the ExecutorService.shutdownNow()
will be called when command terminates - unless it is the ad-hoc
service, which will be shutdown regardlesssendSize - Size (in bytes) of buffer to use when sending filesreceiveSize - Size (in bytes) of buffer to use when receiving filesfileOpener - The ScpFileOpener - if null then DefaultScpFileOpener is usedeventListener - An ScpTransferEventListener - may be nullThreadUtils.newSingleThreadExecutor(String),
ScpHelper.MIN_SEND_BUFFER_SIZE,
ScpHelper.MIN_RECEIVE_BUFFER_SIZEpublic Session getSession()
getSession in interface SessionHolder<Session>public ServerSession getServerSession()
getServerSession in interface ServerSessionHolderServerSession usedpublic void setSession(ServerSession session)
setSession in interface SessionAwaresession - The ServerSession in which this shell will be executed.public void setInputStream(InputStream in)
CommandsetInputStream in interface Commandin - The InputStream used by the shell to read input.public void setOutputStream(OutputStream out)
CommandsetOutputStream in interface Commandout - The OutputStream used by the shell to write its outputpublic void setErrorStream(OutputStream err)
CommandsetErrorStream in interface Commanderr - 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 setFileSystem(FileSystem fs)
FileSystemAwaresetFileSystem in interface FileSystemAwarefs - the file systempublic void start(Environment env) throws IOException
CommandLifecycleRunnable,
and this method should spawn a new thread like:
Thread(this).start();
start in interface CommandLifecycleenv - The EnvironmentIOException - If failed to startpublic void destroy()
CommandLifecycledestroy in interface CommandLifecycleprotected void writeCommandResponseMessage(String command, int exitValue, String exitMessage) throws IOException
IOExceptionCopyright © 2008–2017 The Apache Software Foundation. All rights reserved.