View Javadoc

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