Class JschSession
java.lang.Object
org.eclipse.jgit.transport.ssh.jsch.JschSession
- All Implemented Interfaces:
RemoteSession
,RemoteSession2
Run remote commands using Jsch.
This class is the default session implementation using Jsch. Note that
JschConfigSessionFactory
is used to
create the actual session passed to the constructor.
- Since:
- 6.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
private class
Implementation of Process for running a single command using Jsch. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJschSession
(com.jcraft.jsch.Session session, URIish uri) Create a new session object by passing the real Jsch session and the URI information. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Disconnects the remote session.Creates a new remoteProcess
to execute the given command.Creates a new remoteProcess
to execute the given command.Obtains anFtpChannel
for performing FTP operations over thisRemoteSession
.com.jcraft.jsch.Channel
Deprecated.
-
Field Details
-
sock
final com.jcraft.jsch.Session sock -
uri
-
-
Constructor Details
-
JschSession
Create a new session object by passing the real Jsch session and the URI information.- Parameters:
session
- the real Jsch session created elsewhere.uri
- the URI information for the remote connection
-
-
Method Details
-
exec
Creates a new remoteProcess
to execute the given command. The returned process's streams exist and are connected, and execution of the process is already started.- Specified by:
exec
in interfaceRemoteSession
- Parameters:
command
- command to executetimeout
- timeout value, in seconds, for creating the remote process- Returns:
- a new remote process, already started
- Throws:
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).
-
exec
Creates a new remoteProcess
to execute the given command. The returned process's streams exist and are connected, and execution of the process is already started.- Specified by:
exec
in interfaceRemoteSession2
- Parameters:
command
- command to executeenvironment
- environment variables to pass ontimeout
- timeout value, in seconds, for creating the remote process- Returns:
- a new remote process, already started
- Throws:
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).
-
disconnect
public void disconnect()Disconnects the remote session.- Specified by:
disconnect
in interfaceRemoteSession
-
getSftpChannel
Deprecated.since 5.2; usegetFtpChannel()
insteadA kludge to allowTransportSftp
to get an Sftp channel from Jsch. Ideally, this method would be generic, which would require implementing generic Sftp channel operations in the RemoteSession class.- Returns:
- a channel suitable for Sftp operations.
- Throws:
com.jcraft.jsch.JSchException
- on problems getting the channel.
-
getFtpChannel
Obtains anFtpChannel
for performing FTP operations over thisRemoteSession
. The default implementation returnsnull
.- Specified by:
getFtpChannel
in interfaceRemoteSession
- Returns:
- the
FtpChannel
- Since:
- 5.2
-
getFtpChannel()
instead