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