Top Description Fields Constructors Methods
org.eclipse.jgit.transport

public abstract Class SshTransport

extends TcpTransport
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.transport.TransportGitSsh, org.eclipse.jgit.transport.TransportSftp
Imports
org.eclipse.jgit.errors.TransportException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.Repository, org.eclipse.jgit.util.FS

The base class for transports that use SSH protocol. This class allows customizing SSH connection settings.

Field Summary

Modifier and TypeField and Description
private SshSessionFactory
private RemoteSession
sock

The open SSH session

Constructor Summary

AccessConstructor and Description
protected
SshTransport(Repository
the repository this instance will fetch into, or push out of. This must be the repository passed to open(Repository, URIish).
local
,
URIish
the URI used to access the remote repository. This must be the URI passed to open(Repository, URIish).
uri
)

Create a new transport instance.

protected
SshTransport(URIish
the URI used to access the remote repository. This must be the URI passed to open(URIish).
uri
)

Create a new transport instance without a local repository.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract org.eclipse.jgit.transport.Transport.close.

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

protected RemoteSession

Returns:

a remote session
getSession
()

Get the default SSH session

public SshSessionFactory

Returns:

the SSH session factory that will be used for creating SSH sessions
getSshSessionFactory
()

Get the SSH session factory

public void
setSshSessionFactory(SshSessionFactory
a factory to set, must not be null
factory
)

Set SSH session factory instead of the default one for this instance of the transport.

Field Detail

schback to summary
private SshSessionFactory sch
sockback to summary
private RemoteSession sock

The open SSH session

Constructor Detail

SshTransportback to summary
protected SshTransport(Repository local, URIish uri)

Create a new transport instance.

Parameters
local:Repository

the repository this instance will fetch into, or push out of. This must be the repository passed to open(Repository, URIish).

uri:URIish

the URI used to access the remote repository. This must be the URI passed to open(Repository, URIish).

SshTransportback to summary
protected SshTransport(URIish uri)

Create a new transport instance without a local repository.

Parameters
uri:URIish

the URI used to access the remote repository. This must be the URI passed to open(URIish).

Since
3.5

Method Detail

closeback to summary
public void close()

Implements abstract org.eclipse.jgit.transport.Transport.close.

Implements java.lang.AutoCloseable.close.

Doc from org.eclipse.jgit.transport.Transport.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Close any resources used by this transport.

If the remote repository is contacted by a network socket this method must close that network socket, disconnecting the two peers. If the remote repository is actually local (same system) this method must close any open file handles used to read the "remote" repository.

AutoClosable.close() declares that it throws Exception. Implementers shouldn't throw checked exceptions. This override narrows the signature to prevent them from doing so.

Annotations
@Override
getSessionback to summary
protected RemoteSession getSession() throws TransportException

Get the default SSH session

Returns:RemoteSession

a remote session

Exceptions
TransportException:
in case of error with opening SSH session
getSshSessionFactoryback to summary
public SshSessionFactory getSshSessionFactory()

Get the SSH session factory

Returns:SshSessionFactory

the SSH session factory that will be used for creating SSH sessions

setSshSessionFactoryback to summary
public void setSshSessionFactory(SshSessionFactory factory)

Set SSH session factory instead of the default one for this instance of the transport.

Parameters
factory:SshSessionFactory

a factory to set, must not be null

Exceptions
IllegalStateException:
if session has been already created.