Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 19879 invoked from network); 30 Nov 2008 07:47:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Nov 2008 07:47:27 -0000 Received: (qmail 48863 invoked by uid 500); 30 Nov 2008 07:47:38 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 48813 invoked by uid 500); 30 Nov 2008 07:47:38 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 48804 invoked by uid 99); 30 Nov 2008 07:47:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Nov 2008 23:47:38 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Nov 2008 07:46:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id ABBDF238889D; Sat, 29 Nov 2008 23:46:21 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r721779 - in /geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor: ProgressSpinnerMonitor.java SimpleMonitor.java Date: Sun, 30 Nov 2008 07:46:21 -0000 To: scm@geronimo.apache.org From: jdillon@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081130074621.ABBDF238889D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jdillon Date: Sat Nov 29 23:46:21 2008 New Revision: 721779 URL: http://svn.apache.org/viewvc?rev=721779&view=rev Log: Add a simple download monitor Added: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java (contents, props changed) - copied, changed from r721778, geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java?rev=721779&r1=721778&r2=721779&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java (original) +++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java Sat Nov 29 23:46:21 2008 @@ -65,6 +65,8 @@ public void transferStarted(final TransferEvent event) { assert event != null; + super.transferStarted(event); + complete = 0; spinner.reset(); @@ -74,14 +76,14 @@ String message = type + ": " + location; - log.debug(message); - println(message); } public void transferProgress(final TransferEvent event) { assert event != null; + super.transferProgress(event); + long total = event.getContentLength(); complete += event.getLength(); @@ -94,7 +96,6 @@ message = complete + "/" + (total == TransferEvent.UNKNOWN_LENGTH ? "?" : total + "b"); } - log.trace(message); print(spinner.spin(message)); } Copied: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java (from r721778, geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java) URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java?p2=geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java&p1=geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java&r1=721778&r2=721779&rev=721779&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java (original) +++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java Sat Nov 29 23:46:21 2008 @@ -26,34 +26,20 @@ import java.io.IOException; /** - * A download monitor providing a simple spinning progress interface. + * A simple download monitor. * * @version $Rev$ $Date$ */ -public class ProgressSpinnerMonitor +public class SimpleMonitor extends TransferListenerSupport { - private static final String CARRIAGE_RETURN = "\r"; - private final IO io; - private final ProgressSpinner spinner = new ProgressSpinner(); - - private long complete; - - public ProgressSpinnerMonitor(final IO io) throws IOException { + public SimpleMonitor(final IO io) throws IOException { assert io != null; this.io = io; } - - private void print(final String message) { - if (!io.isQuiet()) { - io.out.print(message); - io.out.print(CARRIAGE_RETURN); - io.out.flush(); - } - } private void println(final String message) { if (!io.isQuiet()) { @@ -65,9 +51,7 @@ public void transferStarted(final TransferEvent event) { assert event != null; - complete = 0; - - spinner.reset(); + super.transferStarted(event); String type = event.getRequestType() == TransferEvent.RequestType.UPLOAD ? "Uploading" : "Downloading"; String location = event.getLocation(); @@ -79,26 +63,6 @@ println(message); } - public void transferProgress(final TransferEvent event) { - assert event != null; - - long total = event.getContentLength(); - complete += event.getLength(); - - String message; - - if (total >= 1024) { - message = complete / 1024 + "/" + (total == TransferEvent.UNKNOWN_LENGTH ? "?" : total / 1024 + "K"); - } - else { - message = complete + "/" + (total == TransferEvent.UNKNOWN_LENGTH ? "?" : total + "b"); - } - - log.trace(message); - - print(spinner.spin(message)); - } - public void transferCompleted(final TransferEvent event) { assert event != null; @@ -108,7 +72,6 @@ String type = event.getRequestType() == TransferEvent.RequestType.UPLOAD ? "Uploaded" : "Downloaded"; String bytes = total >= 1024 ? ( total / 1024 ) + "K" : total + "b"; - // HACK: pad at end just incase, should really blank the reset of the line - print(type + " " + bytes + " "); + println(type + " " + bytes); } } \ No newline at end of file Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java ------------------------------------------------------------------------------ svn:mime-type = text/plain