RemoteSession.java

  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. package org.eclipse.jgit.transport;

  16. import java.io.IOException;

  17. /**
  18.  * An abstraction of a remote "session" for executing remote commands.
  19.  */
  20. public interface RemoteSession {

  21.     /**
  22.      * Creates a new remote {@link Process} to execute the given command. The
  23.      * returned process's streams exist and are connected, and execution of the
  24.      * process is already started.
  25.      *
  26.      * @param commandName
  27.      *            command to execute
  28.      * @param timeout
  29.      *            timeout value, in seconds, for creating the remote process
  30.      * @return a new remote process, already started
  31.      * @throws java.io.IOException
  32.      *             may be thrown in several cases. For example, on problems
  33.      *             opening input or output streams or on problems connecting or
  34.      *             communicating with the remote host. For the latter two cases,
  35.      *             a TransportException may be thrown (a subclass of
  36.      *             java.io.IOException).
  37.      */
  38.     Process exec(String commandName, int timeout) throws IOException;

  39.     /**
  40.      * Obtains an {@link FtpChannel} for performing FTP operations over this
  41.      * {@link RemoteSession}. The default implementation returns {@code null}.
  42.      *
  43.      * @return the {@link FtpChannel}
  44.      * @since 5.2
  45.      */
  46.     default FtpChannel getFtpChannel() {
  47.         return null;
  48.     }

  49.     /**
  50.      * Disconnects the remote session.
  51.      */
  52.     void disconnect();
  53. }