public class ScpCommand extends Object implements Command, Runnable, FileSystemAware
Modifier and Type | Field and Description |
---|---|
protected ExitCallback |
callback |
protected OutputStream |
err |
protected IOException |
error |
protected ExecutorService |
executors |
protected InputStream |
in |
protected static org.slf4j.Logger |
log |
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 FileSystemView |
root |
protected int |
sendBufferSize |
protected boolean |
shutdownExecutor |
Constructor and Description |
---|
ScpCommand(String command)
Simple constructor - uses an ad-hoc
ExecutorService to
run the command as well as default send / receive buffer sizes |
ScpCommand(String command,
ExecutorService executorService) |
ScpCommand(String command,
ExecutorService executorService,
boolean shutdownOnExit) |
ScpCommand(String command,
ExecutorService executorService,
boolean shutdownOnExit,
int bufferSize) |
ScpCommand(String command,
ExecutorService executorService,
boolean shutdownOnExit,
int sendSize,
int receiveSize) |
ScpCommand(String command,
ExecutorService executorService,
int bufferSize) |
ScpCommand(String command,
int bufferSize)
Uses an ad-hoc
ExecutorService to run the command |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroy the shell.
|
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 |
setFileSystemView(FileSystemView view)
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 |
start(Environment env)
Starts the shell.
|
String |
toString() |
protected static final org.slf4j.Logger log
protected String name
protected boolean optR
protected boolean optT
protected boolean optF
protected boolean optD
protected boolean optP
protected FileSystemView root
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
public ScpCommand(String command)
ExecutorService
to
run the command as well as default send / receive buffer sizescommand
- The command to be executedScpCommand(String, ExecutorService, boolean, int, int)
,
ScpHelper.DEFAULT_COPY_BUFFER_SIZE
public ScpCommand(String command, int bufferSize)
ExecutorService
to run the commandcommand
- The command to be executedbufferSize
- Size (in bytes) of buffer to be used for both
sending and receiving filesScpCommand(String, ExecutorService, int)
public ScpCommand(String command, ExecutorService executorService, int bufferSize)
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. Note: the
executor service will not be shutdown when command terminates
unless it is the ad-hoc servicebufferSize
- Size (in bytes) of buffer to be used for both
sending and receiving filesScpCommand(String, ExecutorService, boolean, int, int)
public ScpCommand(String command, ExecutorService executorService)
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. Note: the
executor service will not be shutdown when command terminates
unless it is the ad-hoc serviceScpCommand(String, ExecutorService, boolean, int)
public ScpCommand(String command, ExecutorService executorService, boolean shutdownOnExit)
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 regardlessScpCommand(String, ExecutorService, boolean, int)
,
ScpHelper.DEFAULT_COPY_BUFFER_SIZE
public ScpCommand(String command, ExecutorService executorService, boolean shutdownOnExit, int bufferSize)
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 regardlessbufferSize
- Size (in bytes) of buffer to be used for both
sending and receiving filesScpCommand(String, ExecutorService, boolean, int, int)
public ScpCommand(String command, ExecutorService executorService, boolean shutdownOnExit, int sendSize, int receiveSize)
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 filesThreadUtils.newSingleThreadExecutor(String)
,
ScpHelper.MIN_SEND_BUFFER_SIZE
,
ScpHelper.MIN_RECEIVE_BUFFER_SIZE
public void setInputStream(InputStream in)
Command
setInputStream
in interface Command
public void setOutputStream(OutputStream out)
Command
setOutputStream
in interface Command
public void setErrorStream(OutputStream err)
Command
setErrorStream
in interface Command
public void setExitCallback(ExitCallback callback)
Command
setExitCallback
in interface Command
public void setFileSystemView(FileSystemView view)
FileSystemAware
setFileSystemView
in interface FileSystemAware
public void start(Environment env) throws IOException
Command
Thread(this).start();
start
in interface Command
IOException
public void destroy()
Command
Copyright © 2008–2018 The Apache Software Foundation. All rights reserved.