001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.eclipse.aether.spi.connector.transport; 020 021import java.nio.ByteBuffer; 022 023import org.eclipse.aether.transfer.TransferCancelledException; 024 025/** 026 * A skeleton class for listeners used to monitor transport operations. Reusing common regular expression syntax, the 027 * sequence of events is generally as follows: 028 * 029 * <pre> 030 * ( STARTED PROGRESSED* )* 031 * </pre> 032 * 033 * The methods in this class do nothing. 034 */ 035public abstract class TransportListener { 036 037 /** 038 * Enables subclassing. 039 */ 040 protected TransportListener() {} 041 042 /** 043 * Notifies the listener about the start of the data transfer. This event may arise more than once if the transfer 044 * needs to be restarted (e.g. after an authentication failure). 045 * 046 * @param dataOffset The byte offset in the resource at which the transfer starts, must not be negative. 047 * @param dataLength The total number of bytes in the resource or {@code -1} if the length is unknown. 048 * @throws TransferCancelledException If the transfer should be aborted. 049 */ 050 public void transportStarted(long dataOffset, long dataLength) throws TransferCancelledException {} 051 052 /** 053 * Notifies the listener about some progress in the data transfer. This event may even be fired if actually zero 054 * bytes have been transferred since the last event, for instance to enable cancellation. 055 * 056 * @param data The (read-only) buffer holding the bytes that have just been tranferred, must not be {@code null}. 057 * @throws TransferCancelledException If the transfer should be aborted. 058 */ 059 public void transportProgressed(ByteBuffer data) throws TransferCancelledException {} 060}