Package org.eclipse.jgit.transport.sshd
Class SshdSession
- java.lang.Object
-
- org.eclipse.jgit.transport.sshd.SshdSession
-
- All Implemented Interfaces:
RemoteSession
public class SshdSession extends java.lang.Object implements RemoteSession
An implementation ofRemoteSessionbased on Apache MINA sshd.- Since:
- 5.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static interfaceSshdSession.FtpOperation<T>Helper interface likeSupplier, but possibly raising anIOException.private static classSshdSession.SshdExecProcessprivate classSshdSession.SshdFtpChannel
-
Field Summary
Fields Modifier and Type Field Description private org.apache.sshd.client.SshClientclientprivate java.util.concurrent.CopyOnWriteArrayList<SessionCloseListener>listenersprivate static org.slf4j.LoggerLOGprivate org.apache.sshd.client.session.ClientSessionsessionprivate URIishuri
-
Constructor Summary
Constructors Constructor Description SshdSession(URIish uri, java.util.function.Supplier<org.apache.sshd.client.SshClient> clientFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCloseListener(SessionCloseListener listener)Adds aSessionCloseListenerto this session.(package private) voidconnect(java.time.Duration timeout)voiddisconnect()Disconnects the remote session.private voiddisconnect(java.lang.Throwable reason)java.lang.Processexec(java.lang.String commandName, int timeout)Creates a new remoteProcessto execute the given command.FtpChannelgetFtpChannel()Obtain anFtpChannelto perform SFTP operations in thisSshdSession.private voidnotifyCloseListeners()voidremoveCloseListener(SessionCloseListener listener)Removes the givenlistener; has no effect if the listener is not currently registered with this session.
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
listeners
private final java.util.concurrent.CopyOnWriteArrayList<SessionCloseListener> listeners
-
uri
private final URIish uri
-
client
private org.apache.sshd.client.SshClient client
-
session
private org.apache.sshd.client.session.ClientSession session
-
-
Constructor Detail
-
SshdSession
SshdSession(URIish uri, java.util.function.Supplier<org.apache.sshd.client.SshClient> clientFactory)
-
-
Method Detail
-
connect
void connect(java.time.Duration timeout) throws java.io.IOException- Throws:
java.io.IOException
-
addCloseListener
public void addCloseListener(@NonNull SessionCloseListener listener)
Adds aSessionCloseListenerto this session. Has no effect if the givenlisteneris already registered with this session.- Parameters:
listener- to add
-
removeCloseListener
public void removeCloseListener(@NonNull SessionCloseListener listener)
Removes the givenlistener; has no effect if the listener is not currently registered with this session.- Parameters:
listener- to remove
-
notifyCloseListeners
private void notifyCloseListeners()
-
exec
public java.lang.Process exec(java.lang.String commandName, int timeout) throws java.io.IOExceptionDescription copied from interface:RemoteSessionCreates a new remoteProcessto execute the given command. The returned process's streams exist and are connected, and execution of the process is already started.- Specified by:
execin interfaceRemoteSession- Parameters:
commandName- command to executetimeout- timeout value, in seconds, for creating the remote process- Returns:
- a new remote process, already started
- Throws:
java.io.IOException- may be thrown in several cases. For example, on problems opening input or output streams or on problems connecting or communicating with the remote host. For the latter two cases, a TransportException may be thrown (a subclass of java.io.IOException).
-
getFtpChannel
@NonNull public FtpChannel getFtpChannel()
Obtain anFtpChannelto perform SFTP operations in thisSshdSession.- Specified by:
getFtpChannelin interfaceRemoteSession- Returns:
- the
FtpChannel
-
disconnect
public void disconnect()
Description copied from interface:RemoteSessionDisconnects the remote session.- Specified by:
disconnectin interfaceRemoteSession
-
disconnect
private void disconnect(java.lang.Throwable reason)
-
-