mirror of https://github.com/apache/maven.git
o Changed transfer listener to consequently use the event for data
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@828870 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3a89fb086a
commit
5160b63bc0
|
@ -78,6 +78,14 @@ public class ArtifactTransferEvent
|
|||
|
||||
private ArtifactTransferResource artifact;
|
||||
|
||||
private long transferredBytes;
|
||||
|
||||
private byte[] dataBuffer;
|
||||
|
||||
private int dataOffset;
|
||||
|
||||
private int dataLength;
|
||||
|
||||
public ArtifactTransferEvent( String wagon, final int eventType, final int requestType,
|
||||
ArtifactTransferResource artifact )
|
||||
{
|
||||
|
@ -196,6 +204,46 @@ public class ArtifactTransferEvent
|
|||
this.localFile = localFile;
|
||||
}
|
||||
|
||||
public long getTransferredBytes()
|
||||
{
|
||||
return transferredBytes;
|
||||
}
|
||||
|
||||
public void setTransferredBytes( long transferredBytes )
|
||||
{
|
||||
this.transferredBytes = transferredBytes;
|
||||
}
|
||||
|
||||
public byte[] getDataBuffer()
|
||||
{
|
||||
return dataBuffer;
|
||||
}
|
||||
|
||||
public void setDataBuffer( byte[] dataBuffer )
|
||||
{
|
||||
this.dataBuffer = dataBuffer;
|
||||
}
|
||||
|
||||
public int getDataOffset()
|
||||
{
|
||||
return dataOffset;
|
||||
}
|
||||
|
||||
public void setDataOffset( int dataOffset )
|
||||
{
|
||||
this.dataOffset = dataOffset;
|
||||
}
|
||||
|
||||
public int getDataLength()
|
||||
{
|
||||
return dataLength;
|
||||
}
|
||||
|
||||
public void setDataLength( int dataLength )
|
||||
{
|
||||
this.dataLength = dataLength;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
|
|
@ -29,7 +29,7 @@ public interface ArtifactTransferListener
|
|||
|
||||
void transferStarted( ArtifactTransferEvent transferEvent );
|
||||
|
||||
void transferProgress( ArtifactTransferEvent transferEvent, long transferred, byte[] buffer, int offset, int length );
|
||||
void transferProgress( ArtifactTransferEvent transferEvent );
|
||||
|
||||
void transferCompleted( ArtifactTransferEvent transferEvent );
|
||||
|
||||
|
|
|
@ -65,7 +65,15 @@ public class TransferListenerAdapter
|
|||
|
||||
public void transferCompleted( TransferEvent transferEvent )
|
||||
{
|
||||
listener.transferCompleted( wrap( transferEvent ) );
|
||||
ArtifactTransferEvent event = wrap( transferEvent );
|
||||
|
||||
Long transferred = transfers.get( transferEvent.getResource() );
|
||||
if ( transferred != null )
|
||||
{
|
||||
event.setTransferredBytes( transferred.longValue() );
|
||||
}
|
||||
|
||||
listener.transferCompleted( event );
|
||||
|
||||
artifacts.remove( transferEvent.getResource() );
|
||||
transfers.remove( transferEvent.getResource() );
|
||||
|
@ -95,7 +103,13 @@ public class TransferListenerAdapter
|
|||
}
|
||||
transfers.put( transferEvent.getResource(), transferred );
|
||||
|
||||
listener.transferProgress( wrap( transferEvent ), transferred.longValue(), buffer, 0, length );
|
||||
ArtifactTransferEvent event = wrap( transferEvent );
|
||||
event.setDataBuffer( buffer );
|
||||
event.setDataOffset( 0 );
|
||||
event.setDataLength( length );
|
||||
event.setTransferredBytes( transferred.longValue() );
|
||||
|
||||
listener.transferProgress( event );
|
||||
}
|
||||
|
||||
public void transferStarted( TransferEvent transferEvent )
|
||||
|
|
|
@ -88,19 +88,17 @@ public abstract class AbstractMavenTransferListener
|
|||
// to be overriden by sub classes
|
||||
}
|
||||
|
||||
public void transferProgress( ArtifactTransferEvent transferEvent, long transferred, byte[] buffer, int offset,
|
||||
int length )
|
||||
public void transferProgress( ArtifactTransferEvent transferEvent )
|
||||
{
|
||||
if ( !showEvent( transferEvent ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
doProgress( transferEvent, transferred, buffer, offset, length );
|
||||
doProgress( transferEvent );
|
||||
}
|
||||
|
||||
protected void doProgress( ArtifactTransferEvent transferEvent, long transferred, byte[] buffer, int offset,
|
||||
int length )
|
||||
protected void doProgress( ArtifactTransferEvent transferEvent )
|
||||
{
|
||||
// to be overriden by sub classes
|
||||
}
|
||||
|
@ -118,7 +116,7 @@ public abstract class AbstractMavenTransferListener
|
|||
protected void doCompleted( ArtifactTransferEvent transferEvent )
|
||||
{
|
||||
ArtifactTransferResource artifact = transferEvent.getResource();
|
||||
long contentLength = artifact.getContentLength();
|
||||
long contentLength = transferEvent.getTransferredBytes();
|
||||
if ( contentLength >= 0 )
|
||||
{
|
||||
String type =
|
||||
|
|
|
@ -31,11 +31,10 @@ public class ConsoleMavenTransferListener
|
|||
{
|
||||
|
||||
@Override
|
||||
protected void doProgress( ArtifactTransferEvent transferEvent, long transferred, byte[] buffer, int offset,
|
||||
int length )
|
||||
protected void doProgress( ArtifactTransferEvent transferEvent )
|
||||
{
|
||||
long total = transferEvent.getResource().getContentLength();
|
||||
long complete = transferred;
|
||||
long complete = transferEvent.getTransferredBytes();
|
||||
|
||||
// TODO [BP]: Sys.out may no longer be appropriate, but will \r work with getLogger()?
|
||||
if ( total >= 1024 )
|
||||
|
|
Loading…
Reference in New Issue