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, 2020 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   * An abstraction of a remote "session" for executing remote commands.
22   */
23  public interface RemoteSession {
24  
25  	/**
26  	 * Creates a new remote {@link Process} to execute the given command. The
27  	 * returned process's streams exist and are connected, and execution of the
28  	 * process is already started.
29  	 *
30  	 * @param commandName
31  	 *            command to execute
32  	 * @param timeout
33  	 *            timeout value, in seconds, for creating the remote process
34  	 * @return a new remote process, already started
35  	 * @throws java.io.IOException
36  	 *             may be thrown in several cases. For example, on problems
37  	 *             opening input or output streams or on problems connecting or
38  	 *             communicating with the remote host. For the latter two cases,
39  	 *             a TransportException may be thrown (a subclass of
40  	 *             java.io.IOException).
41  	 */
42  	Process exec(String commandName, int timeout) throws IOException;
43  
44  	/**
45  	 * Obtains an {@link FtpChannel} for performing FTP operations over this
46  	 * {@link RemoteSession}. The default implementation returns {@code null}.
47  	 *
48  	 * @return the {@link FtpChannel}
49  	 * @since 5.2
50  	 */
51  	default FtpChannel getFtpChannel() {
52  		return null;
53  	}
54  
55  	/**
56  	 * Disconnects the remote session.
57  	 */
58  	void disconnect();
59  }