geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r721603 - in /geronimo/gshell/trunk: gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/ gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ gshell-support/gshell-artifact/src/main/java/org/apa...
Date Sat, 29 Nov 2008 00:58:59 GMT
Author: jdillon
Date: Fri Nov 28 16:58:59 2008
New Revision: 721603

URL: http://svn.apache.org/viewvc?rev=721603&view=rev
Log:
More artifact listener muck

Modified:
    geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactResolverImpl.java
    geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferEvent.java
    geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListener.java
    geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListenerSupport.java
    geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java

Modified: geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java?rev=721603&r1=721602&r2=721603&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
(original)
+++ geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
Fri Nov 28 16:58:59 2008
@@ -214,9 +214,11 @@
             builder.setClassLoader(getClass().getClassLoader());
             builder.setIo(io);
 
-            // Configure the download monitor
-            ArtifactResolver artifactResolver = builder.getContainer().getBean(ArtifactResolver.class);
-            artifactResolver.setTransferListener(new ProgressSpinnerMonitor(io));
+            if (!io.isQuiet() && !io.isSilent()) {
+                // Configure the download monitor
+                ArtifactResolver artifactResolver = builder.getContainer().getBean(ArtifactResolver.class);
+                artifactResolver.setTransferListener(new ProgressSpinnerMonitor(io));
+            }
 
             // --help and --version need access to the application's information, so we have
to handle these options late
             if (help|version) {

Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactResolverImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactResolverImpl.java?rev=721603&r1=721602&r2=721603&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactResolverImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/maven/ArtifactResolverImpl.java
Fri Nov 28 16:58:59 2008
@@ -53,8 +53,32 @@
 
     public void setTransferListener(final TransferListener listener) {
         assert listener != null;
-        
-        // TODO: Hookup adapter to wagon manager
+
+        artifactManager.setDownloadMonitor(new org.apache.maven.wagon.events.TransferListener()
{
+            public void transferInitiated(final org.apache.maven.wagon.events.TransferEvent
transferEvent) {
+                // ignore
+            }
+
+            public void transferStarted(final org.apache.maven.wagon.events.TransferEvent
transferEvent) {
+                // TODO:
+            }
+
+            public void transferProgress(final org.apache.maven.wagon.events.TransferEvent
transferEvent, final byte[] buffer, final int length) {
+                // TODO:
+            }
+
+            public void transferCompleted(final org.apache.maven.wagon.events.TransferEvent
transferEvent) {
+                // TODO:
+            }
+
+            public void transferError(final org.apache.maven.wagon.events.TransferEvent transferEvent)
{
+                // TODO:
+            }
+
+            public void debug(final String message) {
+                log.trace(message);
+            }
+        });
     }
 
     public Result resolve(final Request request) throws Failure {

Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferEvent.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferEvent.java?rev=721603&r1=721602&r2=721603&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferEvent.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferEvent.java
Fri Nov 28 16:58:59 2008
@@ -19,6 +19,8 @@
 
 package org.apache.geronimo.gshell.artifact.transfer;
 
+import java.net.URL;
+
 /**
  * Artifact transfer event.
  *
@@ -26,5 +28,23 @@
  */
 public interface TransferEvent
 {
-    // ???
+    enum Type {
+        UPLOAD, DOWNLOAD
+    }
+
+    Type getType();
+
+    URL getUrl();
+
+    /**
+     * The maximum length of the content.
+     */
+    long getContentLength();
+
+    /**
+     * The length of bytes received for this event.
+     */
+    long getLength();
+
+    Throwable getCause();
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListener.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListener.java?rev=721603&r1=721602&r2=721603&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListener.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListener.java
Fri Nov 28 16:58:59 2008
@@ -26,6 +26,8 @@
  */
 public interface TransferListener
 {
+    int UNKNOWN_LENGTH = -1;
+    
     void transferStarted(TransferEvent event);
 
     void transferProgress(TransferEvent event);

Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListenerSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListenerSupport.java?rev=721603&r1=721602&r2=721603&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListenerSupport.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/TransferListenerSupport.java
Fri Nov 28 16:58:59 2008
@@ -45,8 +45,6 @@
     }
 
     public void transferFailed(final TransferEvent event) {
-        log.trace("Transfer error: {}", event);
-
-        log.error("Transfer failure: {}", event);
+        log.trace("Transfer failure: {}", event);
     }
 }
\ No newline at end of file

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=721603&r1=721602&r2=721603&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
Fri Nov 28 16:58:59 2008
@@ -21,8 +21,10 @@
 
 import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.artifact.transfer.TransferListenerSupport;
+import org.apache.geronimo.gshell.artifact.transfer.TransferEvent;
 
 import java.io.IOException;
+import java.net.URL;
 
 /**
  * A download monitor providing a simple spinning progress interface.
@@ -61,39 +63,28 @@
         }
     }
 
-    //
-    // TODO: May actually want to use a little timmer thread to make this spin more often
for better user feedback
-    //       that we are still working, then use the event to update the message.  Or really,
put the timer in
-    //       the spinner impl, and then just update the status message
-    //
-
-    /*
     public void transferStarted(final TransferEvent event) {
         assert event != null;
 
-        super.transferStarted(event);
-
         complete = 0;
 
         spinner.reset();
 
-        String type = event.getRequestType() == REQUEST_PUT ? "Uploading" : "Downloading";
-        String url = event.getWagon().getRepository().getUrl();
+        String type = event.getType() == TransferEvent.Type.UPLOAD ? "Uploading" : "Downloading";
+        URL url = event.getUrl();
 
-        String message = type + ": " + url + "/" + event.getResource().getName();
+        String message = type + ": " + url;
 
         log.debug(message);
 
         println(message);
     }
 
-    public void transferProgress(final TransferEvent event, final byte[] buffer, final int
length) {
+    public void transferProgress(final TransferEvent event) {
         assert event != null;
 
-        super.transferProgress(event, buffer, length);
-
-        long total = event.getResource().getContentLength();
-        complete += length;
+        long total = event.getContentLength();
+        complete += event.getLength();
 
         String message;
 
@@ -114,12 +105,11 @@
 
         super.transferCompleted(event);
 
-        long length = event.getResource().getContentLength();
-        String type = event.getRequestType() == REQUEST_PUT ? "Uploaded" : "Downloaded";
+        long length = event.getLength();
+        String type = event.getType() == TransferEvent.Type.UPLOAD ? "Uploaded" : "Downloaded";
         String bytes = length >= 1024 ? ( length / 1024 ) + "K" : length + "b";
 
         // pad at end just incase, should really blank the reset of the line
         print(type + " " + bytes + "          ");
     }
-    */
 }
\ No newline at end of file



Mime
View raw message