Package org.apache.sshd.scp.server
Class ScpCommandFactory
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.server.command.AbstractDelegatingCommandFactory
org.apache.sshd.scp.server.ScpCommandFactory
- All Implemented Interfaces:
Cloneable
,ExecutorServiceProvider
,ManagedExecutorServiceSupplier
,ScpFileOpenerHolder
,CommandFactory
,ShellFactory
,ShellFactorySelector
public class ScpCommandFactory
extends AbstractDelegatingCommandFactory
implements ManagedExecutorServiceSupplier, ScpFileOpenerHolder, Cloneable, ShellFactory, ShellFactorySelector
This
CommandFactory
can be used as a standalone command factory or can be used to augment another
CommandFactory
and provides SCP
support.- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ShellFactory
private Supplier<? extends CloseableExecutorService>
private ScpFileOpener
private ScpTransferEventListener
private Collection<ScpTransferEventListener>
private int
static final String
private int
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
addEventListener
(ScpTransferEventListener listener) clone()
createShell
(ChannelSession channel) protected Command
executeSupportedCommand
(ChannelSession channel, String command) Supplier<? extends CloseableExecutorService>
int
int
boolean
isSupportedCommand
(ChannelSession channel, String command) boolean
removeEventListener
(ScpTransferEventListener listener) protected CloseableExecutorService
resolveExecutorService
(String command) selectShellFactory
(ChannelSession channelSession) void
setDelegateShellFactory
(ShellFactory delegateShellFactory) void
setExecutorServiceProvider
(Supplier<? extends CloseableExecutorService> provider) void
setReceiveBufferSize
(int receiveSize) void
setScpFileOpener
(ScpFileOpener fileOpener) void
setSendBufferSize
(int sendSize) Methods inherited from class org.apache.sshd.server.command.AbstractDelegatingCommandFactory
createCommand, createUnsupportedCommand, getDelegateCommandFactory, setDelegateCommandFactory, toString
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.sshd.common.util.threads.ExecutorServiceProvider
resolveExecutorService
-
Field Details
-
SCP_FACTORY_NAME
- See Also:
-
executorsProvider
-
fileOpener
-
delegateShellFactory
-
sendBufferSize
private int sendBufferSize -
receiveBufferSize
private int receiveBufferSize -
listeners
-
listenerProxy
-
-
Constructor Details
-
ScpCommandFactory
public ScpCommandFactory()
-
-
Method Details
-
getScpFileOpener
- Specified by:
getScpFileOpener
in interfaceScpFileOpenerHolder
- Returns:
- The last
ScpFileOpener
set via call toScpFileOpenerHolder.setScpFileOpener(ScpFileOpener)
-
setScpFileOpener
- Specified by:
setScpFileOpener
in interfaceScpFileOpenerHolder
- Parameters:
fileOpener
- The defaultScpFileOpener
to use - ifnull
then a default opener is used
-
getExecutorServiceProvider
- Specified by:
getExecutorServiceProvider
in interfaceExecutorServiceProvider
- Returns:
- A
Supplier
ofCloseableExecutorService
to be used when asynchronous execution required. Ifnull
then a single-threaded ad-hoc service is used.
-
setExecutorServiceProvider
- Specified by:
setExecutorServiceProvider
in interfaceManagedExecutorServiceSupplier
- Parameters:
provider
- TheSupplier
ofCloseableExecutorService
-s to be used when asynchronous execution is required. Ifnull
then a single-threaded ad-hoc service is used.
-
getSendBufferSize
public int getSendBufferSize() -
setSendBufferSize
public void setSendBufferSize(int sendSize) - Parameters:
sendSize
- Size (in bytes) of buffer to use when sending files- See Also:
-
getReceiveBufferSize
public int getReceiveBufferSize() -
setReceiveBufferSize
public void setReceiveBufferSize(int receiveSize) - Parameters:
receiveSize
- Size (in bytes) of buffer to use when receiving files- See Also:
-
addEventListener
- Parameters:
listener
- TheScpTransferEventListener
to add- Returns:
true
if this is a new listener instance,false
if the listener is already registered- Throws:
IllegalArgumentException
- ifnull
listener
-
removeEventListener
- Parameters:
listener
- TheScpTransferEventListener
to remove- Returns:
true
if the listener was registered and removed,false
if the listener was not registered to begin with- Throws:
IllegalArgumentException
- ifnull
listener
-
isSupportedCommand
- Specified by:
isSupportedCommand
in classAbstractDelegatingCommandFactory
- Parameters:
channel
- TheChannelSession
through which the command was receivedcommand
- The command about to be executed- Returns:
true
if this command is supported by the command factory,false
if it will be passed on to thedelegate
factory
-
executeSupportedCommand
- Specified by:
executeSupportedCommand
in classAbstractDelegatingCommandFactory
-
getDelegateShellFactory
- Returns:
- The delegate
ShellFactory
to use ifselectShellFactory(ChannelSession)
decides not to use itself as theShellFactory
- default=InteractiveProcessShellFactory
. - See Also:
-
setDelegateShellFactory
- Parameters:
delegateShellFactory
- TheShellFactory
to use ifselectShellFactory(ChannelSession)
decides not to use itself as theShellFactory
. Ifnull
then it will always decide to use itself regardless of theChannelSession
- See Also:
-
selectShellFactory
- Specified by:
selectShellFactory
in interfaceShellFactorySelector
- Parameters:
channelSession
- TheChannelSession
- Returns:
- The
ShellFactory
to use for the channel -null
if none - Throws:
IOException
- If failed the selection
-
createShell
- Specified by:
createShell
in interfaceShellFactory
- Parameters:
channel
- TheChannelSession
through which the command has been received- Returns:
- The
Command
representing the shell to be executed - Throws:
IOException
- If failed to create the shell
-
resolveExecutorService
-
clone
-