001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.eclipse.aether.transfer; 020 021/** 022 * A listener being notified of artifact/metadata transfers from/to remote repositories. The listener may be called from 023 * an arbitrary thread. Reusing common regular expression syntax, the sequence of events is roughly as follows: 024 * 025 * <pre> 026 * INITIATED ( STARTED PROGRESSED* CORRUPTED? )* ( SUCCEEDED | FAILED ) 027 * </pre> 028 * 029 * <em>Note:</em> Implementors are strongly advised to inherit from {@link AbstractTransferListener} instead of directly 030 * implementing this interface. 031 * 032 * @see org.eclipse.aether.RepositorySystemSession#getTransferListener() 033 * @see org.eclipse.aether.RepositoryListener 034 * @noimplement This interface is not intended to be implemented by clients. 035 * @noextend This interface is not intended to be extended by clients. 036 */ 037public interface TransferListener { 038 039 /** 040 * Notifies the listener about the initiation of a transfer. This event gets fired before any actual network access 041 * to the remote repository and usually indicates some thread is now about to perform the transfer. For a given 042 * transfer request, this event is the first one being fired and it must be emitted exactly once. 043 * 044 * @param event The event details, must not be {@code null}. 045 * @throws TransferCancelledException If the transfer should be aborted. 046 */ 047 void transferInitiated(TransferEvent event) throws TransferCancelledException; 048 049 /** 050 * Notifies the listener about the start of a data transfer. This event indicates a successful connection to the 051 * remote repository. In case of a download, the requested remote resource exists and its size is given by 052 * {@link TransferResource#getContentLength()} if possible. This event may be fired multiple times for given 053 * transfer request if said transfer needs to be repeated (e.g. in response to an authentication challenge). 054 * 055 * @param event The event details, must not be {@code null}. 056 * @throws TransferCancelledException If the transfer should be aborted. 057 */ 058 void transferStarted(TransferEvent event) throws TransferCancelledException; 059 060 /** 061 * Notifies the listener about some progress in the data transfer. This event may even be fired if actually zero 062 * bytes have been transferred since the last event, for instance to enable cancellation. 063 * 064 * @param event The event details, must not be {@code null}. 065 * @throws TransferCancelledException If the transfer should be aborted. 066 */ 067 void transferProgressed(TransferEvent event) throws TransferCancelledException; 068 069 /** 070 * Notifies the listener that a checksum validation failed. {@link TransferEvent#getException()} will be of type 071 * {@link ChecksumFailureException} and can be used to query further details about the expected/actual checksums. 072 * 073 * @param event The event details, must not be {@code null}. 074 * @throws TransferCancelledException If the transfer should be aborted. 075 */ 076 void transferCorrupted(TransferEvent event) throws TransferCancelledException; 077 078 /** 079 * Notifies the listener about the successful completion of a transfer. This event must be fired exactly once for a 080 * given transfer request unless said request failed. 081 * 082 * @param event The event details, must not be {@code null}. 083 */ 084 void transferSucceeded(TransferEvent event); 085 086 /** 087 * Notifies the listener about the unsuccessful termination of a transfer. {@link TransferEvent#getException()} will 088 * provide further information about the failure. 089 * 090 * @param event The event details, must not be {@code null}. 091 */ 092 void transferFailed(TransferEvent event); 093}