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