Interface ConnectorFactory
- All Known Implementing Classes:
Factory
public interface ConnectorFactory
A factory for creating
Connector
s. This is a service provider
interface; implementations are discovered via the
ServiceLoader
, or can be set explicitly on a
SshdSessionFactory
.- Since:
- 6.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
-
Method Summary
Modifier and TypeMethodDescriptionCreates a newConnector
.static ConnectorFactory
Retrieves the currently set defaultConnectorFactory
.Tells what kind ofConnector
thisConnectorFactory
creates ifcreate(String, File)
is called withidentityAgent == null
.getName()
Retrieves a name for this factory.Tells which kinds of SSH agents thisConnectorFactory
supports.boolean
Tells whether thisConnectorFactory
is applicable on the currently running platform.static void
setDefault
(ConnectorFactory factory) Sets a defaultConnectorFactory
.
-
Method Details
-
getDefault
Retrieves the currently set defaultConnectorFactory
. This is the factory that is used unless overridden by theSshdSessionFactory
.- Returns:
- the current default factory; may be
null
if none is set and theServiceLoader
cannot find any suitable implementation
-
setDefault
Sets a defaultConnectorFactory
. This is the factory that is used unless overridden by theSshdSessionFactory
.If no default factory is set programmatically, an implementation is discovered via the
ServiceLoader
.- Parameters:
factory
-ConnectorFactory
to set, ornull
to revert to the default behavior of using theServiceLoader
.
-
create
Creates a newConnector
.- Parameters:
identityAgent
- identifies the wanted agent connection; ifnull
, the factory is free to provide aConnector
to a default agent. The value will typically come from theIdentityAgent
setting in~/.ssh/config
.homeDir
- the current local user's home directory as configured in theSshdSessionFactory
- Returns:
- a new
Connector
- Throws:
IOException
- if no connector can be created
-
isSupported
boolean isSupported()Tells whether thisConnectorFactory
is applicable on the currently running platform.- Returns:
true
if the factory can be used,false
otherwise
-
getName
String getName()Retrieves a name for this factory.- Returns:
- the name
-
getSupportedConnectors
Tells which kinds of SSH agents thisConnectorFactory
supports.An implementation of this method should document the possible values it returns.
- Returns:
- an immutable collection of
ConnectorFactory.ConnectorDescriptor
s, includinggetDefaultConnector()
and not including a descriptor for internal name "none"
-
getDefaultConnector
ConnectorFactory.ConnectorDescriptor getDefaultConnector()Tells what kind ofConnector
thisConnectorFactory
creates ifcreate(String, File)
is called withidentityAgent == null
.- Returns:
- a
ConnectorFactory.ConnectorDescriptor
for the default connector
-