Package org.eclipse.aether.util.listener
Class ChainedTransferListener
java.lang.Object
org.eclipse.aether.transfer.AbstractTransferListener
org.eclipse.aether.util.listener.ChainedTransferListener
- All Implemented Interfaces:
TransferListener
A transfer listener that delegates to zero or more other listeners (multicast). The list of target listeners is
thread-safe, i.e. target listeners can be added or removed by any thread at any time.
-
Constructor Summary
ConstructorsConstructorDescriptionChainedTransferListener(Collection<? extends TransferListener> listeners) Creates a new multicast listener that delegates to the specified listeners.ChainedTransferListener(TransferListener... listeners) Creates a new multicast listener that delegates to the specified listeners. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Collection<? extends TransferListener> listeners) Adds the specified listeners to the end of the multicast chain.voidadd(TransferListener listener) Adds the specified listener to the end of the multicast chain.protected voidhandleError(TransferEvent event, TransferListener listener, RuntimeException error) Invoked when any listener throws, by default is no op, extend if required.static TransferListenernewInstance(TransferListener listener1, TransferListener listener2) Creates a new multicast listener that delegates to the specified listeners.voidremove(TransferListener listener) Removes the specified listener from the multicast chain.voidtransferCorrupted(TransferEvent event) Notifies the listener that a checksum validation failed.voidtransferFailed(TransferEvent event) Notifies the listener about the unsuccessful termination of a transfer.voidtransferInitiated(TransferEvent event) Notifies the listener about the initiation of a transfer.voidtransferProgressed(TransferEvent event) Notifies the listener about some progress in the data transfer.voidtransferStarted(TransferEvent event) Notifies the listener about the start of a data transfer.voidtransferSucceeded(TransferEvent event) Notifies the listener about the successful completion of a transfer.
-
Constructor Details
-
ChainedTransferListener
Creates a new multicast listener that delegates to the specified listeners.- Parameters:
listeners- the listeners to delegate to, may benullor empty
-
ChainedTransferListener
Creates a new multicast listener that delegates to the specified listeners.- Parameters:
listeners- the listeners to delegate to, may benullor empty
-
-
Method Details
-
newInstance
Creates a new multicast listener that delegates to the specified listeners. In contrast to the constructor, this factory method will avoid creating an actual chained listener if one of the specified readers is actuallynull.- Parameters:
listener1- the first listener, may benulllistener2- the second listener, may benull- Returns:
- the chained listener or
nullif no listener was supplied
-
add
Adds the specified listeners to the end of the multicast chain.- Parameters:
listeners- the listeners to add, may benullor empty
-
add
Adds the specified listener to the end of the multicast chain.- Parameters:
listener- the listener to add, may benull
-
remove
Removes the specified listener from the multicast chain. Trying to remove a non-existing listener has no effect.- Parameters:
listener- the listener to remove, may benull
-
handleError
Invoked when any listener throws, by default is no op, extend if required. -
transferInitiated
Description copied from interface:TransferListenerNotifies the listener about the initiation of a transfer. This event gets fired before any actual network access to the remote repository and usually indicates some thread is now about to perform the transfer. For a given transfer request, this event is the first one being fired and it must be emitted exactly once.- Specified by:
transferInitiatedin interfaceTransferListener- Overrides:
transferInitiatedin classAbstractTransferListener- Parameters:
event- The event details, must not benull.- Throws:
TransferCancelledException- If the transfer should be aborted.
-
transferStarted
Description copied from interface:TransferListenerNotifies the listener about the start of a data transfer. This event indicates a successful connection to the remote repository. In case of a download, the requested remote resource exists and its size is given byTransferResource.getContentLength()if possible. This event may be fired multiple times for given transfer request if said transfer needs to be repeated (e.g. in response to an authentication challenge).- Specified by:
transferStartedin interfaceTransferListener- Overrides:
transferStartedin classAbstractTransferListener- Parameters:
event- The event details, must not benull.- Throws:
TransferCancelledException- If the transfer should be aborted.
-
transferProgressed
Description copied from interface:TransferListenerNotifies the listener about some progress in the data transfer. This event may even be fired if actually zero bytes have been transferred since the last event, for instance to enable cancellation.- Specified by:
transferProgressedin interfaceTransferListener- Overrides:
transferProgressedin classAbstractTransferListener- Parameters:
event- The event details, must not benull.- Throws:
TransferCancelledException- If the transfer should be aborted.
-
transferCorrupted
Description copied from interface:TransferListenerNotifies the listener that a checksum validation failed.TransferEvent.getException()will be of typeChecksumFailureExceptionand can be used to query further details about the expected/actual checksums.- Specified by:
transferCorruptedin interfaceTransferListener- Overrides:
transferCorruptedin classAbstractTransferListener- Parameters:
event- The event details, must not benull.- Throws:
TransferCancelledException- If the transfer should be aborted.
-
transferSucceeded
Description copied from interface:TransferListenerNotifies the listener about the successful completion of a transfer. This event must be fired exactly once for a given transfer request unless said request failed.- Specified by:
transferSucceededin interfaceTransferListener- Overrides:
transferSucceededin classAbstractTransferListener- Parameters:
event- The event details, must not benull.
-
transferFailed
Description copied from interface:TransferListenerNotifies the listener about the unsuccessful termination of a transfer.TransferEvent.getException()will provide further information about the failure.- Specified by:
transferFailedin interfaceTransferListener- Overrides:
transferFailedin classAbstractTransferListener- Parameters:
event- The event details, must not benull.
-