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; 022import java.util.Map; 023 024import org.eclipse.aether.transfer.TransferCancelledException; 025import org.eclipse.aether.transfer.TransferEvent; 026 027/** 028 * A skeleton class for listeners used to monitor transport operations. Reusing common regular expression syntax, the 029 * sequence of events is generally as follows: 030 * 031 * <pre> 032 * ( STARTED PROGRESSED* )* 033 * </pre> 034 * 035 * The methods in this class do nothing. 036 */ 037public abstract class TransportListener { 038 039 /** 040 * Enables subclassing. 041 */ 042 protected TransportListener() {} 043 044 /** 045 * Notifies the listener about the start of the data transfer. This event may arise more than once if the transfer 046 * needs to be restarted (e.g. after an authentication failure). 047 * 048 * @param dataOffset The byte offset in the resource at which the transfer starts, must not be negative. 049 * @param dataLength The total number of bytes in the resource or {@code -1} if the length is unknown. 050 * @throws TransferCancelledException If the transfer should be aborted. 051 */ 052 public void transportStarted(long dataOffset, long dataLength) throws TransferCancelledException {} 053 054 /** 055 * Notifies the listener about some progress in the data transfer. This event may even be fired if actually zero 056 * bytes have been transferred since the last event, for instance to enable cancellation. 057 * 058 * @param data The (read-only) buffer holding the bytes that have just been tranferred, must not be {@code null}. 059 * @throws TransferCancelledException If the transfer should be aborted. 060 */ 061 public void transportProgressed(ByteBuffer data) throws TransferCancelledException {} 062 063 /** 064 * Notifies the listener about the transport properties that are available for this transfer. 065 * This method is called either before or after other notifications are sent: 066 * <ul> 067 * <li>for remote put tasks this is called after {@link #transportStarted(long, long)}</li> 068 * <li>for remote peek tasks this is is the only event that is called</li> 069 * <li>for all other remote tasks this is called before {@link #transportStarted(long, long)}</li> 070 * </ul> 071 * @param transportProperties The transport properties associated with this transfer, may be empty. The keys are transporter specific and the value types are key specific. 072 * @throws TransferCancelledException If the transfer should be aborted. 073 * @since 2.0.21 074 */ 075 public void transportPropertiesAvailable(Map<TransferEvent.TransportPropertyKey, Object> transportProperties) 076 throws TransferCancelledException {} 077}