public class ScpCommandFactory extends AbstractDelegatingCommandFactory implements ManagedExecutorServiceSupplier, ScpFileOpenerHolder, java.lang.Cloneable, ShellFactory, ShellFactorySelector
CommandFactory
can be used as a standalone command factory or can be used to augment another
CommandFactory
and provides SCP
support.ScpCommand
,
ScpShell
Modifier and Type | Class and Description |
---|---|
static class |
ScpCommandFactory.Builder
A useful
ObjectBuilder for ScpCommandFactory |
Modifier and Type | Field and Description |
---|---|
private ShellFactory |
delegateShellFactory |
private java.util.function.Supplier<? extends CloseableExecutorService> |
executorsProvider |
private ScpFileOpener |
fileOpener |
private ScpTransferEventListener |
listenerProxy |
private java.util.Collection<ScpTransferEventListener> |
listeners |
private int |
receiveBufferSize |
static java.lang.String |
SCP_FACTORY_NAME |
private int |
sendBufferSize |
log
Constructor and Description |
---|
ScpCommandFactory() |
createCommand, createUnsupportedCommand, getDelegateCommandFactory, setDelegateCommandFactory, toString
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
resolveExecutorService
selectShellFactory
split
public static final java.lang.String SCP_FACTORY_NAME
private java.util.function.Supplier<? extends CloseableExecutorService> executorsProvider
private ScpFileOpener fileOpener
private ShellFactory delegateShellFactory
private int sendBufferSize
private int receiveBufferSize
private java.util.Collection<ScpTransferEventListener> listeners
private ScpTransferEventListener listenerProxy
public ScpFileOpener getScpFileOpener()
getScpFileOpener
in interface ScpFileOpenerHolder
ScpFileOpener
set via call to ScpFileOpenerHolder.setScpFileOpener(ScpFileOpener)
public void setScpFileOpener(ScpFileOpener fileOpener)
setScpFileOpener
in interface ScpFileOpenerHolder
fileOpener
- The default ScpFileOpener
to use - if null
then a default opener is usedpublic java.util.function.Supplier<? extends CloseableExecutorService> getExecutorServiceProvider()
getExecutorServiceProvider
in interface ExecutorServiceProvider
Supplier
of CloseableExecutorService
to be used when asynchronous execution required.
If null
then a single-threaded ad-hoc service is used.public void setExecutorServiceProvider(java.util.function.Supplier<? extends CloseableExecutorService> provider)
setExecutorServiceProvider
in interface ManagedExecutorServiceSupplier
provider
- The Supplier
of CloseableExecutorService
-s to be used when asynchronous execution
is required. If null
then a single-threaded ad-hoc service is used.public int getSendBufferSize()
public void setSendBufferSize(int sendSize)
sendSize
- Size (in bytes) of buffer to use when sending filesScpHelper.MIN_SEND_BUFFER_SIZE
public int getReceiveBufferSize()
public void setReceiveBufferSize(int receiveSize)
receiveSize
- Size (in bytes) of buffer to use when receiving filesScpHelper.MIN_RECEIVE_BUFFER_SIZE
public boolean addEventListener(ScpTransferEventListener listener)
listener
- The ScpTransferEventListener
to addtrue
if this is a new listener instance, false
if the
listener is already registeredjava.lang.IllegalArgumentException
- if null
listenerpublic boolean removeEventListener(ScpTransferEventListener listener)
listener
- The ScpTransferEventListener
to removetrue
if the listener was registered and removed, false
if the
listener was not registered to begin withjava.lang.IllegalArgumentException
- if null
listenerpublic boolean isSupportedCommand(ChannelSession channel, java.lang.String command)
isSupportedCommand
in class AbstractDelegatingCommandFactory
channel
- The ChannelSession
through which the command was receivedcommand
- The command about to be executedtrue
if this command is supported by the command factory, false
if it will be
passed on to the delegate
factoryprotected Command executeSupportedCommand(ChannelSession channel, java.lang.String command)
executeSupportedCommand
in class AbstractDelegatingCommandFactory
public ShellFactory getDelegateShellFactory()
ShellFactory
to use if selectShellFactory(ChannelSession)
decides not to
use itself as the ShellFactory
- default=InteractiveProcessShellFactory
.setDelegateShellFactory(ShellFactory)
public void setDelegateShellFactory(ShellFactory delegateShellFactory)
delegateShellFactory
- The ShellFactory
to use if selectShellFactory(ChannelSession)
decides not to use itself as the ShellFactory
. If null
then it will
always decide to use itself regardless of the ChannelSession
selectShellFactory(ChannelSession)
public ShellFactory selectShellFactory(ChannelSession channelSession) throws java.io.IOException
selectShellFactory
in interface ShellFactorySelector
channelSession
- The ChannelSession
ShellFactory
to use for the channel - null
if nonejava.io.IOException
- If failed the selectionpublic Command createShell(ChannelSession channel) throws java.io.IOException
createShell
in interface ShellFactory
channel
- The ChannelSession
through which the command has been receivedCommand
representing the shell to be executedjava.io.IOException
- If failed to create the shellprotected CloseableExecutorService resolveExecutorService(java.lang.String command)
public ScpCommandFactory clone()
clone
in class java.lang.Object