1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.transport.wagon;
20
21 import java.nio.ByteBuffer;
22
23 import org.apache.maven.wagon.events.TransferEvent;
24 import org.apache.maven.wagon.observers.AbstractTransferListener;
25 import org.eclipse.aether.spi.connector.transport.TransportListener;
26 import org.eclipse.aether.transfer.TransferCancelledException;
27
28
29
30
31 final class WagonTransferListener extends AbstractTransferListener {
32
33 private final TransportListener listener;
34
35 WagonTransferListener(TransportListener listener) {
36 this.listener = listener;
37 }
38
39 @Override
40 public void transferStarted(TransferEvent event) {
41 try {
42 listener.transportStarted(0, event.getResource().getContentLength());
43 } catch (TransferCancelledException e) {
44
45
46
47
48 }
49 }
50
51 @Override
52 public void transferProgress(TransferEvent event, byte[] buffer, int length) {
53 try {
54 listener.transportProgressed(ByteBuffer.wrap(buffer, 0, length));
55 } catch (TransferCancelledException e) {
56 throw new WagonCancelledException(e);
57 }
58 }
59 }