You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2011/10/31 16:00:50 UTC

svn commit: r1195496 - in /maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner: AbstractJarSignerRequest.java DefaultJarSigner.java JarSignerCommandLineBuilder.java JarSignerRequest.java JarSignerSignRequest.java

Author: olamy
Date: Mon Oct 31 15:00:50 2011
New Revision: 1195496

URL: http://svn.apache.org/viewvc?rev=1195496&view=rev
Log:
[MSHARED-212] make stream consumer injectable
Submitted by Tony Chemit.

Modified:
    maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/AbstractJarSignerRequest.java
    maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/DefaultJarSigner.java
    maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerCommandLineBuilder.java
    maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerRequest.java
    maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerSignRequest.java

Modified: maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/AbstractJarSignerRequest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/AbstractJarSignerRequest.java?rev=1195496&r1=1195495&r2=1195496&view=diff
==============================================================================
--- maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/AbstractJarSignerRequest.java (original)
+++ maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/AbstractJarSignerRequest.java Mon Oct 31 15:00:50 2011
@@ -19,6 +19,8 @@ package org.apache.maven.shared.jarsigne
  * under the License.
  */
 
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
 import java.io.File;
 
 /**
@@ -57,6 +59,16 @@ public abstract class AbstractJarSignerR
      */
     private File archive;
 
+    /**
+     * Optional system out stream consumer used by the commandline execution.
+     */
+    private StreamConsumer systemOutStreamConsumer;
+
+    /**
+     * Optional system error stream consumer used by the commandline execution.
+     */
+    private StreamConsumer systemErrorStreamConsumer;
+
     public boolean isVerbose()
     {
         return verbose;
@@ -82,6 +94,16 @@ public abstract class AbstractJarSignerR
         return archive;
     }
 
+    public StreamConsumer getSystemOutStreamConsumer()
+    {
+        return systemOutStreamConsumer;
+    }
+
+    public StreamConsumer getSystemErrorStreamConsumer()
+    {
+        return systemErrorStreamConsumer;
+    }
+
     public void setVerbose( boolean verbose )
     {
         this.verbose = verbose;
@@ -106,4 +128,14 @@ public abstract class AbstractJarSignerR
     {
         this.archive = archive;
     }
+
+    public void setSystemOutStreamConsumer( StreamConsumer systemOutStreamConsumer )
+    {
+        this.systemOutStreamConsumer = systemOutStreamConsumer;
+    }
+
+    public void setSystemErrorStreamConsumer( StreamConsumer systemErrorStreamConsumer )
+    {
+        this.systemErrorStreamConsumer = systemErrorStreamConsumer;
+    }
 }

Modified: maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/DefaultJarSigner.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/DefaultJarSigner.java?rev=1195496&r1=1195495&r2=1195496&view=diff
==============================================================================
--- maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/DefaultJarSigner.java (original)
+++ maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/DefaultJarSigner.java Mon Oct 31 15:00:50 2011
@@ -112,32 +112,42 @@ public class DefaultJarSigner
             }
 
         };
-        StreamConsumer systemOut = new StreamConsumer()
-        {
+        StreamConsumer systemOut = request.getSystemOutStreamConsumer();
 
-            public void consumeLine( final String line )
+        if ( systemOut == null )
+        {
+            systemOut = new StreamConsumer()
             {
-                if ( verbose )
-                {
-                    getLogger().info( line );
-                }
-                else
+
+                public void consumeLine( final String line )
                 {
-                    getLogger().debug( line );
+                    if ( verbose )
+                    {
+                        getLogger().info( line );
+                    }
+                    else
+                    {
+                        getLogger().debug( line );
+                    }
                 }
-            }
 
-        };
+            };
+        }
 
-        StreamConsumer systemErr = new StreamConsumer()
-        {
+        StreamConsumer systemErr = request.getSystemErrorStreamConsumer();
 
-            public void consumeLine( final String line )
+        if (systemErr==null)
+        {
+            systemErr = new StreamConsumer()
             {
-                getLogger().warn( line );
-            }
 
-        };
+                public void consumeLine( final String line )
+                {
+                    getLogger().warn( line );
+                }
+
+            };
+        }
 
         DefaultJarSignerResult result = new DefaultJarSignerResult();
         result.setCommandline( cli );

Modified: maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerCommandLineBuilder.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerCommandLineBuilder.java?rev=1195496&r1=1195495&r2=1195496&view=diff
==============================================================================
--- maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerCommandLineBuilder.java (original)
+++ maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerCommandLineBuilder.java Mon Oct 31 15:00:50 2011
@@ -24,6 +24,7 @@ import org.codehaus.plexus.logging.conso
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.cli.Commandline;
 
+import java.io.File;
 import java.io.IOException;
 
 /**

Modified: maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerRequest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerRequest.java?rev=1195496&r1=1195495&r2=1195496&view=diff
==============================================================================
--- maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerRequest.java (original)
+++ maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerRequest.java Mon Oct 31 15:00:50 2011
@@ -19,6 +19,8 @@ package org.apache.maven.shared.jarsigne
  * under the License.
  */
 
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
 import java.io.File;
 
 /**
@@ -30,23 +32,113 @@ import java.io.File;
  */
 public interface JarSignerRequest
 {
+
+    /**
+     * Gets the value of the {@code verbose} field.
+     *
+     * @return the value of the {@code verbose} field.
+     */
+
     boolean isVerbose();
 
+    /**
+     * Gets the value of the {@code maxMemory} field.
+     *
+     * @return the value of the {@code maxMemory} field.
+     */
     String getMaxMemory();
 
+    /**
+     * Gets the value of the {@code maxMemory} field.
+     *
+     * @return the value of the {@code maxMemory} field.
+     */
     String[] getArguments();
 
+    /**
+     * Gets the value of the {@code workingDirectory} field.
+     *
+     * @return the value of the {@code workingDirectory} field.
+     */
     File getWorkingDirectory();
 
+    /**
+     * Gets the value of the {@code archive} field.
+     * <p/>
+     * The archive field is in fact the file on which the jarsigner request will be executed.
+     *
+     * @return the value of the {@code archive} field.
+     */
     File getArchive();
 
+    /**
+     * Gets the value of the {@code systemOutStreamConsumer} field.
+     * <p/>
+     * This option field if filled is used by the commandline tool to consume system ouput stream of the jarsigner
+     * command.
+     *
+     * @return the value of the {@code systemOutStreamConsumer} field.
+     */
+    StreamConsumer getSystemOutStreamConsumer();
+
+    /**
+     * Gets the value of the {@code systemErrorStreamConsumer} field.
+     * <p/>
+     * This option field if filled is used by the commandline tool to consume system error stream of the jarsigner
+     * command.
+     *
+     * @return the value of the {@code systemErrorStreamConsumer} field.
+     */
+    StreamConsumer getSystemErrorStreamConsumer();
+
+    /**
+     * Sets the new given value to the field {@code verbose} of the request.
+     *
+     * @param verbose the new value of the field {@code verbose}.
+     */
     void setVerbose( boolean verbose );
 
+    /**
+     * Sets the new given value to the field {@code maxMemory} of the request.
+     *
+     * @param maxMemory the new value of the field {@code maxMemory}.
+     */
     void setMaxMemory( String maxMemory );
 
+    /**
+     * Sets the new given value to the field {@code arguments} of the request.
+     *
+     * @param arguments the new value of the field {@code arguments}.
+     */
     void setArguments( String[] arguments );
 
+    /**
+     * Sets the new given value to the field {@code workingDirectory} of the request.
+     *
+     * @param workingDirectory the new value of the field {@code workingDirectory}.
+     */
     void setWorkingDirectory( File workingDirectory );
 
+    /**
+     * Sets the new given value to the field {@code archive} of the request.
+     *
+     * @param archive the new value of the field {@code archive}.
+     */
     void setArchive( File archive );
+
+    /**
+     * Sets the new given value to the field {@code systemOutStreamConsumer} of the request.
+     *
+     * @param systemOutStreamConsumer the new value of the field {@code systemOutStreamConsumer}.
+     */
+    void setSystemOutStreamConsumer( StreamConsumer systemOutStreamConsumer );
+
+    /**
+     * Sets the new given value to the field {@code systemErrorStreamConsumer} of the request.
+     *
+     * @param systemErrorStreamConsumer the new value of the field {@code systemErrorStreamConsumer}.
+     */
+    void setSystemErrorStreamConsumer( StreamConsumer systemErrorStreamConsumer );
+
+
 }

Modified: maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerSignRequest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerSignRequest.java?rev=1195496&r1=1195495&r2=1195496&view=diff
==============================================================================
--- maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerSignRequest.java (original)
+++ maven/shared/trunk/maven-jarsigner/src/main/java/org/apache/maven/shared/jarsigner/JarSignerSignRequest.java Mon Oct 31 15:00:50 2011
@@ -19,6 +19,8 @@ package org.apache.maven.shared.jarsigne
  * under the License.
  */
 
+import java.io.File;
+
 /**
  * Specifies the parameters used to control a jar signer sign operation invocation.
  *
@@ -79,6 +81,7 @@ public class JarSignerSignRequest
      */
     protected String signedjar;
 
+
     public String getKeystore()
     {
         return keystore;
@@ -178,4 +181,5 @@ public class JarSignerSignRequest
     {
         this.signedjar = signedjar;
     }
+
 }