ProtocolV2Hook.java

  1. /*
  2.  * Copyright (C) 2018, Google LLC. and others
  3.  *
  4.  * This program and the accompanying materials are made available under the
  5.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  6.  * https://www.eclipse.org/org/documents/edl-v10.php.
  7.  *
  8.  * SPDX-License-Identifier: BSD-3-Clause
  9.  */
  10. package org.eclipse.jgit.transport;

  11. /**
  12.  * Hook to allow callers to be notified on Git protocol v2 requests.
  13.  *
  14.  * @see UploadPack#setProtocolV2Hook(ProtocolV2Hook)
  15.  * @since 5.1
  16.  */
  17. public interface ProtocolV2Hook {
  18.     /**
  19.      * The default hook implementation that does nothing.
  20.      */
  21.     static ProtocolV2Hook DEFAULT = new ProtocolV2Hook() {
  22.         // No override.
  23.     };

  24.     /**
  25.      * @param req
  26.      *            the capabilities request
  27.      * @throws ServiceMayNotContinueException
  28.      *             abort; the message will be sent to the user
  29.      * @since 5.1
  30.      */
  31.     default void onCapabilities(CapabilitiesV2Request req)
  32.             throws ServiceMayNotContinueException {
  33.         // Do nothing by default.
  34.     }

  35.     /**
  36.      * @param req
  37.      *            the ls-refs request
  38.      * @throws ServiceMayNotContinueException
  39.      *             abort; the message will be sent to the user
  40.      * @since 5.1
  41.      */
  42.     default void onLsRefs(LsRefsV2Request req)
  43.             throws ServiceMayNotContinueException {
  44.         // Do nothing by default.
  45.     }

  46.     /**
  47.      * @param req the fetch request
  48.      * @throws ServiceMayNotContinueException abort; the message will be sent to the user
  49.      */
  50.     default void onFetch(FetchV2Request req)
  51.             throws ServiceMayNotContinueException {
  52.         // Do nothing by default
  53.     }
  54. }