Top Description Inners Fields Constructors Methods
org.apache.sshd.scp.server

public Class ScpCommandFactory

extends AbstractDelegatingCommandFactory
implements ManagedExecutorServiceSupplier, ScpFileOpenerHolder, Cloneable, ShellFactory, ShellFactorySelector
Class Inheritance
All Implemented Interfaces
org.apache.sshd.server.shell.ShellFactorySelector, org.apache.sshd.server.shell.ShellFactory, java.lang.Cloneable, org.apache.sshd.scp.common.ScpFileOpenerHolder, org.apache.sshd.common.util.threads.ManagedExecutorServiceSupplier, org.apache.sshd.common.util.threads.ExecutorServiceProvider
Imports
java.io.IOException, java.util.Collection, java.util.concurrent.CopyOnWriteArraySet, java.util.function.Supplier, org.apache.sshd.common.session.SessionContext, org.apache.sshd.common.util.EventListenerUtils, .GenericUtils, .ObjectBuilder, org.apache.sshd.common.util.threads.CloseableExecutorService, .ManagedExecutorServiceSupplier, org.apache.sshd.scp.ScpModuleProperties, org.apache.sshd.scp.common.ScpFileOpener, .ScpFileOpenerHolder, .ScpHelper, .ScpTransferEventListener, org.apache.sshd.server.channel.ChannelSession, org.apache.sshd.server.command.AbstractDelegatingCommandFactory, .Command, .CommandFactory, org.apache.sshd.server.shell.InteractiveProcessShellFactory, .ShellFactory, .ShellFactorySelector

This CommandFactory can be used as a standalone command factory or can be used to augment another CommandFactory and provides SCP support.
Author
Apache MINA SSHD Project
See Also
ScpCommand, ScpShell

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private ShellFactory
private Supplier<? extends CloseableExecutorService>
private ScpFileOpener
private ScpTransferEventListener
private Collection<ScpTransferEventListener>
private int
public static final String
private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if this is a new listener instance, false if the listener is already registered
addEventListener
(ScpTransferEventListener listener)

public ScpCommandFactory
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

public Command
createShell(ChannelSession
The ChannelSession through which the command has been received
channel
)

Implements org.apache.sshd.server.shell.ShellFactory.createShell.

protected Command
public ShellFactory

Returns:

The delegate ShellFactory to use if selectShellFactory(ChannelSession) decides not to use itself as the ShellFactory - default=InteractiveProcessShellFactory.
getDelegateShellFactory
()

public Supplier<? extends CloseableExecutorService>
public int
public ScpFileOpener
public int
public boolean
isSupportedCommand(ChannelSession
The ChannelSession through which the command was received
channel
,
String
The command about to be executed
command
)

Implements abstract org.apache.sshd.server.command.AbstractDelegatingCommandFactory.isSupportedCommand.

public boolean

Returns:

true if the listener was registered and removed, false if the listener was not registered to begin with
removeEventListener
(ScpTransferEventListener listener)

protected CloseableExecutorService
public ShellFactory
public void
setDelegateShellFactory(ShellFactory
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
delegateShellFactory
)

public void
setExecutorServiceProvider(Supplier<? extends CloseableExecutorService>
The Supplier of CloseableExecutorService-s to be used when asynchronous execution is required. If null then a single-threaded ad-hoc service is used.
provider
)

Implements org.apache.sshd.common.util.threads.ManagedExecutorServiceSupplier.setExecutorServiceProvider.

public void
setReceiveBufferSize(int
Size (in bytes) of buffer to use when receiving files
receiveSize
)

public void
setScpFileOpener(ScpFileOpener
The default ScpFileOpener to use - if null then a default opener is used
fileOpener
)

Implements org.apache.sshd.scp.common.ScpFileOpenerHolder.setScpFileOpener.

public void
setSendBufferSize(int
Size (in bytes) of buffer to use when sending files
sendSize
)

Inherited from org.apache.sshd.server.command.AbstractDelegatingCommandFactory:
createCommandcreateUnsupportedCommandgetDelegateCommandFactorysetDelegateCommandFactorytoString

Field Detail

delegateShellFactoryback to summary
private ShellFactory delegateShellFactory
executorsProviderback to summary
private Supplier<? extends CloseableExecutorService> executorsProvider
fileOpenerback to summary
private ScpFileOpener fileOpener
listenerProxyback to summary
private ScpTransferEventListener listenerProxy
listenersback to summary
private Collection<ScpTransferEventListener> listeners
receiveBufferSizeback to summary
private int receiveBufferSize
SCP_FACTORY_NAMEback to summary
public static final String SCP_FACTORY_NAME
sendBufferSizeback to summary
private int sendBufferSize

Constructor Detail

ScpCommandFactoryback to summary
public ScpCommandFactory()

Method Detail

addEventListenerback to summary
public boolean addEventListener(ScpTransferEventListener listener)
Parameters
listener:ScpTransferEventListener

The ScpTransferEventListener to add

Returns:boolean

true if this is a new listener instance, false if the listener is already registered

Exceptions
IllegalArgumentException:
if null listener
cloneback to summary
public ScpCommandFactory clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:ScpCommandFactory

a clone of this instance.

Annotations
@Override
createShellback to summary
public Command createShell(ChannelSession channel) throws IOException

Implements org.apache.sshd.server.shell.ShellFactory.createShell.

Parameters
channel:ChannelSession

Doc from org.apache.sshd.server.shell.ShellFactory.createShell.

The ChannelSession through which the command has been received

Returns:Command

Doc from org.apache.sshd.server.shell.ShellFactory.createShell.

The Command representing the shell to be executed

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.sshd.server.shell.ShellFactory.createShell.

If failed to create the shell

executeSupportedCommandback to summary
protected Command executeSupportedCommand(ChannelSession channel, String command)

Implements abstract org.apache.sshd.server.command.AbstractDelegatingCommandFactory.executeSupportedCommand.

Annotations
@Override
getDelegateShellFactoryback to summary
public ShellFactory getDelegateShellFactory()
Returns:ShellFactory

The delegate ShellFactory to use if selectShellFactory(ChannelSession) decides not to use itself as the ShellFactory - default=InteractiveProcessShellFactory.

See Also
setDelegateShellFactory(ShellFactory)
getExecutorServiceProviderback to summary
public Supplier<? extends CloseableExecutorService> getExecutorServiceProvider()

Implements org.apache.sshd.common.util.threads.ExecutorServiceProvider.getExecutorServiceProvider.

Returns:Supplier<? extends CloseableExecutorService>

Doc from org.apache.sshd.common.util.threads.ExecutorServiceProvider.getExecutorServiceProvider.

A Supplier of CloseableExecutorService to be used when asynchronous execution required. If null then a single-threaded ad-hoc service is used.

Annotations
@Override
getReceiveBufferSizeback to summary
public int getReceiveBufferSize()
getScpFileOpenerback to summary
public ScpFileOpener getScpFileOpener()

Implements org.apache.sshd.scp.common.ScpFileOpenerHolder.getScpFileOpener.

Returns:ScpFileOpener

Doc from org.apache.sshd.scp.common.ScpFileOpenerHolder.getScpFileOpener.

The last ScpFileOpener set via call to setScpFileOpener(ScpFileOpener)

Annotations
@Override
getSendBufferSizeback to summary
public int getSendBufferSize()
isSupportedCommandback to summary
public boolean isSupportedCommand(ChannelSession channel, String command)

Implements abstract org.apache.sshd.server.command.AbstractDelegatingCommandFactory.isSupportedCommand.

Parameters
channel:ChannelSession

Doc from org.apache.sshd.server.command.AbstractDelegatingCommandFactory.isSupportedCommand.

The ChannelSession through which the command was received

command:String

Doc from org.apache.sshd.server.command.AbstractDelegatingCommandFactory.isSupportedCommand.

The command about to be executed

Returns:boolean

Doc from org.apache.sshd.server.command.AbstractDelegatingCommandFactory.isSupportedCommand.

true if this command is supported by the command factory, false if it will be passed on to the delegate factory

Annotations
@Override
removeEventListenerback to summary
public boolean removeEventListener(ScpTransferEventListener listener)
Parameters
listener:ScpTransferEventListener

The ScpTransferEventListener to remove

Returns:boolean

true if the listener was registered and removed, false if the listener was not registered to begin with

Exceptions
IllegalArgumentException:
if null listener
resolveExecutorServiceback to summary
protected CloseableExecutorService resolveExecutorService(String command)
selectShellFactoryback to summary
public ShellFactory selectShellFactory(ChannelSession channelSession) throws IOException

Implements org.apache.sshd.server.shell.ShellFactorySelector.selectShellFactory.

Parameters
channelSession:ChannelSession

Doc from org.apache.sshd.server.shell.ShellFactorySelector.selectShellFactory.

The ChannelSession

Returns:ShellFactory

Doc from org.apache.sshd.server.shell.ShellFactorySelector.selectShellFactory.

The ShellFactory to use for the channel - null if none

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.sshd.server.shell.ShellFactorySelector.selectShellFactory.

If failed the selection

setDelegateShellFactoryback to summary
public void setDelegateShellFactory(ShellFactory delegateShellFactory)
Parameters
delegateShellFactory:ShellFactory

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

See Also
selectShellFactory(ChannelSession)
setExecutorServiceProviderback to summary
public void setExecutorServiceProvider(Supplier<? extends CloseableExecutorService> provider)

Implements org.apache.sshd.common.util.threads.ManagedExecutorServiceSupplier.setExecutorServiceProvider.

Parameters
provider:Supplier<? extends CloseableExecutorService>

Doc from org.apache.sshd.common.util.threads.ManagedExecutorServiceSupplier.setExecutorServiceProvider.

The Supplier of CloseableExecutorService-s to be used when asynchronous execution is required. If null then a single-threaded ad-hoc service is used.

Annotations
@Override
setReceiveBufferSizeback to summary
public void setReceiveBufferSize(int receiveSize)
Parameters
receiveSize:int

Size (in bytes) of buffer to use when receiving files

See Also
ScpHelper#MIN_RECEIVE_BUFFER_SIZE
setScpFileOpenerback to summary
public void setScpFileOpener(ScpFileOpener fileOpener)

Implements org.apache.sshd.scp.common.ScpFileOpenerHolder.setScpFileOpener.

Parameters
fileOpener:ScpFileOpener

Doc from org.apache.sshd.scp.common.ScpFileOpenerHolder.setScpFileOpener.

The default ScpFileOpener to use - if null then a default opener is used

Annotations
@Override
setSendBufferSizeback to summary
public void setSendBufferSize(int sendSize)
Parameters
sendSize:int

Size (in bytes) of buffer to use when sending files

See Also
ScpHelper#MIN_SEND_BUFFER_SIZE
org.apache.sshd.scp.server back to summary

public Class ScpCommandFactory.Builder

extends Object
implements ObjectBuilder<ScpCommandFactory>
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.util.ObjectBuilder, java.util.function.Supplier

A useful ObjectBuilder for ScpCommandFactory

Field Summary

Modifier and TypeField and Description
private final ScpCommandFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ScpCommandFactory.Builder
public ScpCommandFactory
public ScpCommandFactory.Builder
public ScpCommandFactory.Builder
public ScpCommandFactory.Builder
public ScpCommandFactory.Builder
public ScpCommandFactory.Builder
public ScpCommandFactory.Builder
withReceiveBufferSize(int receiveSize)

public ScpCommandFactory.Builder
withSendBufferSize(int sendSize)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

factoryback to summary
private final ScpCommandFactory factory

Constructor Detail

Builderback to summary
public Builder()

Method Detail

addEventListenerback to summary
public ScpCommandFactory.Builder addEventListener(ScpTransferEventListener listener)
buildback to summary
public ScpCommandFactory build()

Implements org.apache.sshd.common.util.ObjectBuilder.build.

Annotations
@Override
removeEventListenerback to summary
public ScpCommandFactory.Builder removeEventListener(ScpTransferEventListener listener)
withDelegateback to summary
public ScpCommandFactory.Builder withDelegate(CommandFactory delegate)
withDelegateShellFactoryback to summary
public ScpCommandFactory.Builder withDelegateShellFactory(ShellFactory shellFactory)
withExecutorServiceProviderback to summary
public ScpCommandFactory.Builder withExecutorServiceProvider(Supplier<? extends CloseableExecutorService> provider)
withFileOpenerback to summary
public ScpCommandFactory.Builder withFileOpener(ScpFileOpener opener)
withReceiveBufferSizeback to summary
public ScpCommandFactory.Builder withReceiveBufferSize(int receiveSize)
withSendBufferSizeback to summary
public ScpCommandFactory.Builder withSendBufferSize(int sendSize)