public class ScpCommand extends AbstractLoggingBean implements Command, Runnable, FileSystemAware, SessionAware, 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 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,
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() |
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 String name
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 int sendBufferSize
protected int receiveBufferSize
protected ScpTransferEventListener listener
protected ServerSession serverSession
public ScpCommand(String command, ExecutorService executorService, boolean shutdownOnExit, int sendSize, int receiveSize, 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 fileseventListener
- An ScpTransferEventListener
- may be null
ThreadUtils.newSingleThreadExecutor(String)
,
ScpHelper.MIN_SEND_BUFFER_SIZE
,
ScpHelper.MIN_RECEIVE_BUFFER_SIZE
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 void setInputStream(InputStream in)
Command
setInputStream
in interface Command
in
- The InputStream
used by the shell to read input.public void setOutputStream(OutputStream out)
Command
setOutputStream
in interface Command
out
- The OutputStream
used by the shell to write its outputpublic void setErrorStream(OutputStream err)
Command
setErrorStream
in interface Command
err
- The OutputStream
used by the shell to write its errorspublic void setExitCallback(ExitCallback callback)
Command
setExitCallback
in interface Command
callback
- The ExitCallback
to call when shell is closedpublic void setFileSystem(FileSystem fs)
FileSystemAware
setFileSystem
in interface FileSystemAware
fs
- the file systempublic 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
Copyright © 2008–2016 The Apache Software Foundation. All rights reserved.