View Javadoc
1   package org.eclipse.aether.spi.connector.transport;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   * 
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.nio.ByteBuffer;
23  
24  import org.eclipse.aether.transfer.TransferCancelledException;
25  
26  /**
27   * A skeleton class for listeners used to monitor transport operations. Reusing common regular expression syntax, the
28   * sequence of events is generally as follows:
29   * 
30   * <pre>
31   * ( STARTED PROGRESSED* )*
32   * </pre>
33   * 
34   * The methods in this class do nothing.
35   */
36  public abstract class TransportListener
37  {
38  
39      /**
40       * Enables subclassing.
41       */
42      protected TransportListener()
43      {
44      }
45  
46      /**
47       * Notifies the listener about the start of the data transfer. This event may arise more than once if the transfer
48       * needs to be restarted (e.g. after an authentication failure).
49       * 
50       * @param dataOffset The byte offset in the resource at which the transfer starts, must not be negative.
51       * @param dataLength The total number of bytes in the resource or {@code -1} if the length is unknown.
52       * @throws TransferCancelledException If the transfer should be aborted.
53       */
54      public void transportStarted( long dataOffset, long dataLength )
55          throws TransferCancelledException
56      {
57      }
58  
59      /**
60       * Notifies the listener about some progress in the data transfer. This event may even be fired if actually zero
61       * bytes have been transferred since the last event, for instance to enable cancellation.
62       * 
63       * @param data The (read-only) buffer holding the bytes that have just been tranferred, must not be {@code null}.
64       * @throws TransferCancelledException If the transfer should be aborted.
65       */
66      public void transportProgressed( ByteBuffer data )
67          throws TransferCancelledException
68      {
69      }
70  
71  }