View Javadoc
1   /*
2    * Copyright (C) 2009, Constantine Plotnikov <constantine.plotnikov@gmail.com>
3    * Copyright (C) 2008-2009, Google Inc.
4    * Copyright (C) 2009, Google, Inc.
5    * Copyright (C) 2009, JetBrains s.r.o.
6    * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
7    * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
8    *
9    * This program and the accompanying materials are made available under the
10   * terms of the Eclipse Distribution License v. 1.0 which is available at
11   * https://www.eclipse.org/org/documents/edl-v10.php.
12   *
13   * SPDX-License-Identifier: BSD-3-Clause
14   */
15  
16  package org.eclipse.jgit.transport;
17  
18  import java.io.IOException;
19  
20  /**
21   * Create a remote "session" for executing remote commands.
22   * <p>
23   * Clients should subclass RemoteSession to create an alternate way for JGit to
24   * execute remote commands. (The client application may already have this
25   * functionality available.) Note that this class is just a factory for creating
26   * remote processes. If the application already has a persistent connection to
27   * the remote machine, RemoteSession may do nothing more than return a new
28   * RemoteProcess when exec is called.
29   */
30  public interface RemoteSession {
31  	/**
32  	 * Generate a new remote process to execute the given command. This function
33  	 * should also start execution and may need to create the streams prior to
34  	 * execution.
35  	 *
36  	 * @param commandName
37  	 *            command to execute
38  	 * @param timeout
39  	 *            timeout value, in seconds, for command execution
40  	 * @return a new remote process
41  	 * @throws java.io.IOException
42  	 *             may be thrown in several cases. For example, on problems
43  	 *             opening input or output streams or on problems connecting or
44  	 *             communicating with the remote host. For the latter two cases,
45  	 *             a TransportException may be thrown (a subclass of
46  	 *             java.io.IOException).
47  	 */
48  	Process exec(String commandName, int timeout) throws IOException;
49  
50  	/**
51  	 * Obtain an {@link FtpChannel} for performing FTP operations over this
52  	 * {@link RemoteSession}. The default implementation returns {@code null}.
53  	 *
54  	 * @return the {@link FtpChannel}
55  	 * @since 5.2
56  	 */
57  	default FtpChannel getFtpChannel() {
58  		return null;
59  	}
60  
61  	/**
62  	 * Disconnect the remote session
63  	 */
64  	void disconnect();
65  }