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
public final class ChainedTransferListener extends AbstractTransferListener
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
Constructors Constructor Description ChainedTransferListener(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Collection<? extends TransferListener> listeners)
Adds the specified listeners to the end of the multicast chain.void
add(TransferListener listener)
Adds the specified listener to the end of the multicast chain.protected void
handleError(TransferEvent event, TransferListener listener, RuntimeException error)
static TransferListener
newInstance(TransferListener listener1, TransferListener listener2)
Creates a new multicast listener that delegates to the specified listeners.void
remove(TransferListener listener)
Removes the specified listener from the multicast chain.void
transferCorrupted(TransferEvent event)
void
transferFailed(TransferEvent event)
void
transferInitiated(TransferEvent event)
void
transferProgressed(TransferEvent event)
void
transferStarted(TransferEvent event)
void
transferSucceeded(TransferEvent event)
-
-
-
Constructor Detail
-
ChainedTransferListener
public ChainedTransferListener(TransferListener... listeners)
Creates a new multicast listener that delegates to the specified listeners.- Parameters:
listeners
- The listeners to delegate to, may benull
or empty.
-
ChainedTransferListener
public ChainedTransferListener(Collection<? extends TransferListener> listeners)
Creates a new multicast listener that delegates to the specified listeners.- Parameters:
listeners
- The listeners to delegate to, may benull
or empty.
-
-
Method Detail
-
newInstance
public static TransferListener newInstance(TransferListener listener1, TransferListener listener2)
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 benull
.listener2
- The second listener, may benull
.- Returns:
- The chained listener or
null
if no listener was supplied.
-
add
public void add(Collection<? extends TransferListener> listeners)
Adds the specified listeners to the end of the multicast chain.- Parameters:
listeners
- The listeners to add, may benull
or empty.
-
add
public void add(TransferListener listener)
Adds the specified listener to the end of the multicast chain.- Parameters:
listener
- The listener to add, may benull
.
-
remove
public void remove(TransferListener listener)
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
protected void handleError(TransferEvent event, TransferListener listener, RuntimeException error)
-
transferInitiated
public void transferInitiated(TransferEvent event) throws TransferCancelledException
- Specified by:
transferInitiated
in interfaceTransferListener
- Overrides:
transferInitiated
in classAbstractTransferListener
- Throws:
TransferCancelledException
-
transferStarted
public void transferStarted(TransferEvent event) throws TransferCancelledException
- Specified by:
transferStarted
in interfaceTransferListener
- Overrides:
transferStarted
in classAbstractTransferListener
- Throws:
TransferCancelledException
-
transferProgressed
public void transferProgressed(TransferEvent event) throws TransferCancelledException
- Specified by:
transferProgressed
in interfaceTransferListener
- Overrides:
transferProgressed
in classAbstractTransferListener
- Throws:
TransferCancelledException
-
transferCorrupted
public void transferCorrupted(TransferEvent event) throws TransferCancelledException
- Specified by:
transferCorrupted
in interfaceTransferListener
- Overrides:
transferCorrupted
in classAbstractTransferListener
- Throws:
TransferCancelledException
-
transferSucceeded
public void transferSucceeded(TransferEvent event)
- Specified by:
transferSucceeded
in interfaceTransferListener
- Overrides:
transferSucceeded
in classAbstractTransferListener
-
transferFailed
public void transferFailed(TransferEvent event)
- Specified by:
transferFailed
in interfaceTransferListener
- Overrides:
transferFailed
in classAbstractTransferListener
-
-