HttpTransport.java

  1. /*
  2.  * Copyright (C) 2009, Constantine Plotnikov <constantine.plotnikov@gmail.com>
  3.  * Copyright (C) 2009, JetBrains s.r.o.
  4.  * Copyright (C) 2009, Shawn O. Pearce <spearce@spearce.org> and others
  5.  *
  6.  * This program and the accompanying materials are made available under the
  7.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  8.  * https://www.eclipse.org/org/documents/edl-v10.php.
  9.  *
  10.  * SPDX-License-Identifier: BSD-3-Clause
  11.  */

  12. package org.eclipse.jgit.transport;

  13. import org.eclipse.jgit.lib.Repository;
  14. import org.eclipse.jgit.transport.http.HttpConnectionFactory;
  15. import org.eclipse.jgit.transport.http.JDKHttpConnectionFactory;

  16. /**
  17.  * The base class for transports that use HTTP as underlying protocol. This class
  18.  * allows customizing HTTP connection settings.
  19.  */
  20. public abstract class HttpTransport extends Transport {
  21.     /**
  22.      * factory for creating HTTP connections
  23.      *
  24.      * @since 3.3
  25.      */
  26.     protected static volatile HttpConnectionFactory connectionFactory = new JDKHttpConnectionFactory();

  27.     /**
  28.      * Get the {@link org.eclipse.jgit.transport.http.HttpConnectionFactory}
  29.      * used to create new connections
  30.      *
  31.      * @return the {@link org.eclipse.jgit.transport.http.HttpConnectionFactory}
  32.      *         used to create new connections
  33.      * @since 3.3
  34.      */
  35.     public static HttpConnectionFactory getConnectionFactory() {
  36.         return connectionFactory;
  37.     }

  38.     /**
  39.      * Set the {@link org.eclipse.jgit.transport.http.HttpConnectionFactory} to
  40.      * be used to create new connections
  41.      *
  42.      * @param cf
  43.      *            connection factory
  44.      * @since 3.3
  45.      */
  46.     public static void setConnectionFactory(HttpConnectionFactory cf) {
  47.         connectionFactory = cf;
  48.     }

  49.     /**
  50.      * Create a new transport instance.
  51.      *
  52.      * @param local
  53.      *            the repository this instance will fetch into, or push out of.
  54.      *            This must be the repository passed to
  55.      *            {@link #open(Repository, URIish)}.
  56.      * @param uri
  57.      *            the URI used to access the remote repository. This must be the
  58.      *            URI passed to {@link #open(Repository, URIish)}.
  59.      */
  60.     protected HttpTransport(Repository local, URIish uri) {
  61.         super(local, uri);
  62.     }

  63.     /**
  64.      * Create a minimal HTTP transport instance not tied to a single repository.
  65.      *
  66.      * @param uri a {@link org.eclipse.jgit.transport.URIish} object.
  67.      */
  68.     protected HttpTransport(URIish uri) {
  69.         super(uri);
  70.     }
  71. }