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 ShellFactoryprivate Supplier<? extends CloseableExecutorService> private ScpFileOpenerprivate ScpTransferEventListenerprivate Collection<ScpTransferEventListener> private intstatic final Stringprivate intFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddEventListener(ScpTransferEventListener listener) clone()createShell(ChannelSession channel) protected CommandexecuteSupportedCommand(ChannelSession channel, String command) Supplier<? extends CloseableExecutorService> intintbooleanisSupportedCommand(ChannelSession channel, String command) booleanremoveEventListener(ScpTransferEventListener listener) protected CloseableExecutorServiceresolveExecutorService(String command) selectShellFactory(ChannelSession channelSession) voidsetDelegateShellFactory(ShellFactory delegateShellFactory) voidsetExecutorServiceProvider(Supplier<? extends CloseableExecutorService> provider) voidsetReceiveBufferSize(int receiveSize) voidsetScpFileOpener(ScpFileOpener fileOpener) voidsetSendBufferSize(int sendSize) Methods inherited from class org.apache.sshd.server.command.AbstractDelegatingCommandFactory
createCommand, createUnsupportedCommand, getDelegateCommandFactory, setDelegateCommandFactory, toStringMethods 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, warnMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
getScpFileOpenerin interfaceScpFileOpenerHolder- Returns:
- The last
ScpFileOpenerset via call toScpFileOpenerHolder.setScpFileOpener(ScpFileOpener)
-
setScpFileOpener
- Specified by:
setScpFileOpenerin interfaceScpFileOpenerHolder- Parameters:
fileOpener- The defaultScpFileOpenerto use - ifnullthen a default opener is used
-
getExecutorServiceProvider
- Specified by:
getExecutorServiceProviderin interfaceExecutorServiceProvider- Returns:
- A
SupplierofCloseableExecutorServiceto be used when asynchronous execution required. Ifnullthen a single-threaded ad-hoc service is used.
-
setExecutorServiceProvider
- Specified by:
setExecutorServiceProviderin interfaceManagedExecutorServiceSupplier- Parameters:
provider- TheSupplierofCloseableExecutorService-s to be used when asynchronous execution is required. Ifnullthen 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- TheScpTransferEventListenerto add- Returns:
trueif this is a new listener instance,falseif the listener is already registered- Throws:
IllegalArgumentException- ifnulllistener
-
removeEventListener
- Parameters:
listener- TheScpTransferEventListenerto remove- Returns:
trueif the listener was registered and removed,falseif the listener was not registered to begin with- Throws:
IllegalArgumentException- ifnulllistener
-
isSupportedCommand
- Specified by:
isSupportedCommandin classAbstractDelegatingCommandFactory- Parameters:
channel- TheChannelSessionthrough which the command was receivedcommand- The command about to be executed- Returns:
trueif this command is supported by the command factory,falseif it will be passed on to thedelegatefactory
-
executeSupportedCommand
- Specified by:
executeSupportedCommandin classAbstractDelegatingCommandFactory
-
getDelegateShellFactory
- Returns:
- The delegate
ShellFactoryto use ifselectShellFactory(ChannelSession)decides not to use itself as theShellFactory- default=InteractiveProcessShellFactory. - See Also:
-
setDelegateShellFactory
- Parameters:
delegateShellFactory- TheShellFactoryto use ifselectShellFactory(ChannelSession)decides not to use itself as theShellFactory. Ifnullthen it will always decide to use itself regardless of theChannelSession- See Also:
-
selectShellFactory
- Specified by:
selectShellFactoryin interfaceShellFactorySelector- Parameters:
channelSession- TheChannelSession- Returns:
- The
ShellFactoryto use for the channel -nullif none - Throws:
IOException- If failed the selection
-
createShell
- Specified by:
createShellin interfaceShellFactory- Parameters:
channel- TheChannelSessionthrough which the command has been received- Returns:
- The
Commandrepresenting the shell to be executed - Throws:
IOException- If failed to create the shell
-
resolveExecutorService
-
clone
-