1 package hudson.maven; 2 3 import hudson.model.TaskListener; 4 import org.apache.maven.wagon.events.TransferEvent; 5 import org.apache.maven.wagon.events.TransferListener; 6 7 import java.io.PrintStream ; 8 9 18 final class TransferListenerImpl implements TransferListener { 19 22 private final PrintStream out; 23 24 private long transferedSize; 25 26 27 public TransferListenerImpl(TaskListener listener) { 28 this.out = listener.getLogger(); 29 } 30 31 public void transferInitiated( TransferEvent e ) 32 { 33 String url = e.getWagon().getRepository().getUrl(); 34 35 if(e.getRequestType()==TransferEvent.REQUEST_PUT) { 36 out.println("Uploading to "+url); 37 } else { 38 out.println("Downloading "+url); 39 } 40 } 41 42 public void transferStarted(TransferEvent e) { 43 transferedSize = 0; 44 long total = e.getResource().getContentLength(); 45 out.println(HEADER+" start "+total); 46 } 47 48 public void transferProgress(TransferEvent e, byte[] buffer, int length) { 49 transferedSize += length; 50 out.println(HEADER + " progress " + transferedSize); 51 } 52 53 public void transferCompleted(TransferEvent e) { 54 out.println(HEADER + " completed"); 55 } 56 57 public void transferError(TransferEvent e) { 58 out.println(HEADER + " error"); 59 e.getException().printStackTrace(out); 60 } 61 62 public void debug(String message) { 63 } 64 65 68 public static final String HEADER = "[:TRANSFER:]"; 69 } 70 | Popular Tags |