Interface ConnectorFactory
-
- All Known Implementing Classes:
Factory
public interface ConnectorFactoryA factory for creatingConnectors. This is a service provider interface; implementations are discovered via theServiceLoader, or can be set explicitly on aSshdSessionFactory.- Since:
- 6.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceConnectorFactory.ConnectorDescriptor
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Connectorcreate(java.lang.String identityAgent, java.io.File homeDir)Creates a newConnector.static ConnectorFactorygetDefault()Retrieves the currently set defaultConnectorFactory.ConnectorFactory.ConnectorDescriptorgetDefaultConnector()Tells what kind ofConnectorthisConnectorFactorycreates ifcreate(String, File)is called withidentityAgent == null.java.lang.StringgetName()Retrieves a name for this factory.java.util.Collection<ConnectorFactory.ConnectorDescriptor>getSupportedConnectors()Tells which kinds of SSH agents thisConnectorFactorysupports.booleanisSupported()Tells whether thisConnectorFactoryis applicable on the currently running platform.static voidsetDefault(ConnectorFactory factory)Sets a defaultConnectorFactory.
-
-
-
Method Detail
-
getDefault
static ConnectorFactory getDefault()
Retrieves the currently set defaultConnectorFactory. This is the factory that is used unless overridden by theSshdSessionFactory.- Returns:
- the current default factory; may be
nullif none is set and theServiceLoadercannot find any suitable implementation
-
setDefault
static void setDefault(ConnectorFactory factory)
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-ConnectorFactoryto set, ornullto revert to the default behavior of using theServiceLoader.
-
create
@NonNull Connector create(java.lang.String identityAgent, java.io.File homeDir) throws java.io.IOException
Creates a newConnector.- Parameters:
identityAgent- identifies the wanted agent connection; ifnull, the factory is free to provide aConnectorto a default agent. The value will typically come from theIdentityAgentsetting in~/.ssh/config.homeDir- the current local user's home directory as configured in theSshdSessionFactory- Returns:
- a new
Connector - Throws:
java.io.IOException- if no connector can be created
-
isSupported
boolean isSupported()
Tells whether thisConnectorFactoryis applicable on the currently running platform.- Returns:
trueif the factory can be used,falseotherwise
-
getName
java.lang.String getName()
Retrieves a name for this factory.- Returns:
- the name
-
getSupportedConnectors
@NonNull java.util.Collection<ConnectorFactory.ConnectorDescriptor> getSupportedConnectors()
Tells which kinds of SSH agents thisConnectorFactorysupports.An implementation of this method should document the possible values it returns.
- Returns:
- an immutable collection of
ConnectorFactory.ConnectorDescriptors, includinggetDefaultConnector()and not including a descriptor for internal name "none"
-
getDefaultConnector
ConnectorFactory.ConnectorDescriptor getDefaultConnector()
Tells what kind ofConnectorthisConnectorFactorycreates ifcreate(String, File)is called withidentityAgent == null.- Returns:
- a
ConnectorFactory.ConnectorDescriptorfor the default connector
-
-