1 /******************************************************************************* 2 * Copyright (c) 2010, 2014 Sonatype, Inc. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * Sonatype, Inc. - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.aether.transfer; 12 13 /** 14 * A listener being notified of artifact/metadata transfers from/to remote repositories. The listener may be called from 15 * an arbitrary thread. Reusing common regular expression syntax, the sequence of events is roughly as follows: 16 * 17 * <pre> 18 * INITIATED ( STARTED PROGRESSED* CORRUPTED? )* ( SUCCEEDED | FAILED ) 19 * </pre> 20 * 21 * <em>Note:</em> Implementors are strongly advised to inherit from {@link AbstractTransferListener} instead of directly 22 * implementing this interface. 23 * 24 * @see org.eclipse.aether.RepositorySystemSession#getTransferListener() 25 * @see org.eclipse.aether.RepositoryListener 26 * @noimplement This interface is not intended to be implemented by clients. 27 * @noextend This interface is not intended to be extended by clients. 28 */ 29 public interface TransferListener 30 { 31 32 /** 33 * Notifies the listener about the initiation of a transfer. This event gets fired before any actual network access 34 * to the remote repository and usually indicates some thread is now about to perform the transfer. For a given 35 * transfer request, this event is the first one being fired and it must be emitted exactly once. 36 * 37 * @param event The event details, must not be {@code null}. 38 * @throws TransferCancelledException If the transfer should be aborted. 39 */ 40 void transferInitiated( TransferEvent event ) 41 throws TransferCancelledException; 42 43 /** 44 * Notifies the listener about the start of a data transfer. This event indicates a successful connection to the 45 * remote repository. In case of a download, the requested remote resource exists and its size is given by 46 * {@link TransferResource#getContentLength()} if possible. This event may be fired multiple times for given 47 * transfer request if said transfer needs to be repeated (e.g. in response to an authentication challenge). 48 * 49 * @param event The event details, must not be {@code null}. 50 * @throws TransferCancelledException If the transfer should be aborted. 51 */ 52 void transferStarted( TransferEvent event ) 53 throws TransferCancelledException; 54 55 /** 56 * Notifies the listener about some progress in the data transfer. This event may even be fired if actually zero 57 * bytes have been transferred since the last event, for instance to enable cancellation. 58 * 59 * @param event The event details, must not be {@code null}. 60 * @throws TransferCancelledException If the transfer should be aborted. 61 */ 62 void transferProgressed( TransferEvent event ) 63 throws TransferCancelledException; 64 65 /** 66 * Notifies the listener that a checksum validation failed. {@link TransferEvent#getException()} will be of type 67 * {@link ChecksumFailureException} and can be used to query further details about the expected/actual checksums. 68 * 69 * @param event The event details, must not be {@code null}. 70 * @throws TransferCancelledException If the transfer should be aborted. 71 */ 72 void transferCorrupted( TransferEvent event ) 73 throws TransferCancelledException; 74 75 /** 76 * Notifies the listener about the successful completion of a transfer. This event must be fired exactly once for a 77 * given transfer request unless said request failed. 78 * 79 * @param event The event details, must not be {@code null}. 80 */ 81 void transferSucceeded( TransferEvent event ); 82 83 /** 84 * Notifies the listener about the unsuccessful termination of a transfer. {@link TransferEvent#getException()} will 85 * provide further information about the failure. 86 * 87 * @param event The event details, must not be {@code null}. 88 */ 89 void transferFailed( TransferEvent event ); 90 91 }