Package org.apache.sshd.server.scp
Class ScpCommand
-
- All Implemented Interfaces:
Runnable
,FileSystemAware
,SessionContextHolder
,SessionHolder<ServerSession>
,ExecutorServiceCarrier
,Command
,CommandLifecycle
,ServerSessionHolder
,SessionAware
public class ScpCommand extends AbstractFileSystemCommand
This commands provide SCP support on both server and client side. Permissions and preservation of access / modification times on files are not supported.- Author:
- Apache MINA SSHD Project
-
-
Field Summary
Fields Modifier and Type Field Description protected IOException
error
protected ScpTransferEventListener
listener
protected ScpFileOpener
opener
protected boolean
optD
protected boolean
optF
protected boolean
optP
protected boolean
optR
protected boolean
optT
protected String
path
protected int
receiveBufferSize
protected int
sendBufferSize
-
Fields inherited from class org.apache.sshd.server.command.AbstractFileSystemCommand
fileSystem
-
Fields inherited from class org.apache.sshd.server.command.AbstractCommandSupport
callback, cbCalled, cmdFuture, cmdRunner, command, environment, err, executorService, in, out, serverSession
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description ScpCommand(String command, CloseableExecutorService executorService, int sendSize, int receiveSize, ScpFileOpener fileOpener, ScpTransferEventListener eventListener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
run()
void
start(ChannelSession channel, Environment env)
Starts the command execution.String
toString()
protected void
writeCommandResponseMessage(String command, int exitValue, String exitMessage)
-
Methods inherited from class org.apache.sshd.server.command.AbstractFileSystemCommand
destroy, getFileSystem, setFileSystem
-
Methods inherited from class org.apache.sshd.server.command.AbstractCommandSupport
getCommand, getEnvironment, getErrorStream, getExecutorService, getExitCallback, getInputStream, getOutputStream, getServerSession, getSession, getStartedCommandFuture, onExit, onExit, setErrorStream, setExitCallback, setInputStream, setOutputStream, setSession
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
getSimplifiedLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.session.SessionHolder
getSessionContext
-
-
-
-
Field Detail
-
sendBufferSize
protected final int sendBufferSize
-
receiveBufferSize
protected final int receiveBufferSize
-
opener
protected final ScpFileOpener opener
-
optR
protected boolean optR
-
optT
protected boolean optT
-
optF
protected boolean optF
-
optD
protected boolean optD
-
optP
protected boolean optP
-
path
protected String path
-
error
protected IOException error
-
listener
protected ScpTransferEventListener listener
-
-
Constructor Detail
-
ScpCommand
public ScpCommand(String command, CloseableExecutorService executorService, int sendSize, int receiveSize, ScpFileOpener fileOpener, ScpTransferEventListener eventListener)
- Parameters:
command
- The command to be executedexecutorService
- AnCloseableExecutorService
to be used whenstart(ChannelSession, Environment)
-ing execution. Ifnull
an ad-hoc single-threaded service is created and used.sendSize
- Size (in bytes) of buffer to use when sending filesreceiveSize
- Size (in bytes) of buffer to use when receiving filesfileOpener
- TheScpFileOpener
- ifnull
thenDefaultScpFileOpener
is usedeventListener
- AnScpTransferEventListener
- may benull
- See Also:
ThreadUtils.newSingleThreadExecutor(String)
,ScpHelper.MIN_SEND_BUFFER_SIZE
,ScpHelper.MIN_RECEIVE_BUFFER_SIZE
-
-
Method Detail
-
start
public void start(ChannelSession channel, Environment env) throws IOException
Description copied from interface:CommandLifecycle
Starts the command execution. All streams must have been set before calling this method. The command should implementRunnable
, and this method should spawn a new thread like:Thread(this).start();
- Specified by:
start
in interfaceCommandLifecycle
- Overrides:
start
in classAbstractCommandSupport
- Parameters:
channel
- TheChannelSession
through which the command has been receivedenv
- TheEnvironment
- Throws:
IOException
- If failed to start
-
run
public void run()
-
writeCommandResponseMessage
protected void writeCommandResponseMessage(String command, int exitValue, String exitMessage) throws IOException
- Throws:
IOException
-
toString
public String toString()
- Overrides:
toString
in classAbstractCommandSupport
-
-