Author: tchemit
Date: Tue Dec 17 21:29:15 2013
New Revision: 1551722

URL: http://svn.apache.org/r1551722
Log:
MSHARED-304 - Create a API for java tool
Simplify API ( move JavaToolResult contract to a simple Pojo )

Removed:
    
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaToolResult.java
Modified:
    
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java
    
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaTool.java
    
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolResult.java

Modified: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java?rev=1551722&r1=1551721&r2=1551722&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java
 (original)
+++ 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java
 Tue Dec 17 21:29:15 2013
@@ -38,9 +38,9 @@ import java.util.Map;
  * @author Tony Chemit <che...@codelutin.com>
  * @since 0.5
  */
-public abstract class AbstractJavaTool<Request extends JavaToolRequest, Result 
extends JavaToolResult>
+public abstract class AbstractJavaTool<Request extends JavaToolRequest>
     extends AbstractLogEnabled
-    implements JavaTool<Request, Result>
+    implements JavaTool<Request>
 {
 
     /**
@@ -74,8 +74,6 @@ public abstract class AbstractJavaTool<R
     protected abstract Commandline createCommandLine( Request request, String 
javaToolFile )
         throws JavaToolException;
 
-    protected abstract Result createResult();
-
     /**
      * {@inheritDoc}
      */
@@ -95,7 +93,7 @@ public abstract class AbstractJavaTool<R
     /**
      * {@inheritDoc}
      */
-    public Result execute( Request request )
+    public JavaToolResult execute( Request request )
         throws JavaToolException
     {
 
@@ -118,7 +116,7 @@ public abstract class AbstractJavaTool<R
         Commandline cli = createCommandLine( request, javaToolFile );
 
         // execute it
-        Result result = executeCommandLine( cli, request );
+        JavaToolResult result = executeCommandLine( cli, request );
 
         // return result
         return result;
@@ -141,14 +139,14 @@ public abstract class AbstractJavaTool<R
         return systemIn;
     }
 
-    protected Result executeCommandLine( Commandline cli, Request request )
+    protected JavaToolResult executeCommandLine( Commandline cli, Request 
request )
     {
         if ( getLogger().isDebugEnabled() )
         {
             getLogger().debug( "Executing: " + cli );
         }
 
-        Result result = createResult();
+        JavaToolResult result = createResult();
 
         result.setCommandline( cli );
 
@@ -218,6 +216,11 @@ public abstract class AbstractJavaTool<R
         return systemOut;
     }
 
+    protected JavaToolResult createResult()
+    {
+        return new JavaToolResult();
+    }
+
     protected String findJavaToolExecutable()
     {
         String command = javaToolName + ( Os.isFamily( Os.FAMILY_WINDOWS ) ? 
".exe" : "" );

Modified: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaTool.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaTool.java?rev=1551722&r1=1551721&r2=1551722&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaTool.java
 (original)
+++ 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaTool.java
 Tue Dec 17 21:29:15 2013
@@ -33,14 +33,14 @@ import org.apache.maven.toolchain.Toolch
  * @author Tony Chemit <che...@codelutin.com>
  * @since 0.5
  */
-public interface JavaTool<Request extends JavaToolRequest, Result extends 
JavaToolResult>
+public interface JavaTool<Request extends JavaToolRequest>
 {
 
     /**
      * Return the name of the java tool. This is exactly the name (without his 
extension) of the executable to
      * find in the {@code jdk/bin} directory.
      * <p/>
-     * For example: {@code jarsigner, keytoll, javadoc, ...}
+     * For example: {@code jarsigner, keytool, javadoc, ...}
      *
      * @return the name of the java tool.
      */
@@ -58,13 +58,13 @@ public interface JavaTool<Request extend
      * <p/>
      * If could not create the java tool invocation, a {@link 
JavaToolException} will be thrown.
      * <p/>
-     * If execution fails, then the result will have a none-zero {@link 
Result#getExitCode()} and his
-     * {@link Result#getExecutionException()} will be filled with the error, 
otherwise the exist code will be zero.
+     * If execution fails, then the result will have a none-zero {@link 
JavaToolResult#getExitCode()} and his
+     * {@link JavaToolResult#getExecutionException()} will be filled with the 
error, otherwise the exist code will be zero.
      *
      * @param request the request to perform
      * @return the result of the tool execution
      * @throws JavaToolException if could not create the java tool invocation
      */
-    Result execute( Request request )
+    JavaToolResult execute( Request request )
         throws JavaToolException;
 }

Modified: 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolResult.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolResult.java?rev=1551722&r1=1551721&r2=1551722&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolResult.java
 (original)
+++ 
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/JavaToolResult.java
 Tue Dec 17 21:29:15 2013
@@ -28,22 +28,23 @@ import org.apache.maven.shared.utils.cli
  * @author Tony Chemit <che...@codelutin.com>
  * @since 0.5
  */
-public interface JavaToolResult
+public class JavaToolResult
 {
     /**
-     * Gets the command line used.
-     *
-     * @return The command line used
+     * The exception that prevented to execute the command line, will be 
<code>null</code> if jarSigner could be
+     * successfully started.
      */
-    Commandline getCommandline();
+    private CommandLineException executionException;
 
     /**
-     * Gets the exception that possibly occurred during the execution of the 
command line.
-     *
-     * @return The exception that prevented to invoke tool or 
<code>null</code> if the command line was successfully
-     *         processed by the operating system.
+     * The exit code reported by the Maven invocation.
      */
-    CommandLineException getExecutionException();
+    private int exitCode = Integer.MIN_VALUE;
+
+    /**
+     * The command line used to obtain this result.
+     */
+    private Commandline commandline;
 
     /**
      * Gets the exit code from the tool invocation. A non-zero value indicates 
a build failure. <strong>Note:</strong>
@@ -51,26 +52,59 @@ public interface JavaToolResult
      *
      * @return The exit code from the tool invocation.
      */
-    int getExitCode();
+    public int getExitCode()
+    {
+        return exitCode;
+    }
+
+    /**
+     * Gets the command line used.
+     *
+     * @return The command line used
+     */
+    public Commandline getCommandline()
+    {
+        return commandline;
+    }
+
+    /**
+     * Gets the exception that possibly occurred during the execution of the 
command line.
+     *
+     * @return The exception that prevented to invoke tool or 
<code>null</code> if the command line was successfully
+     * processed by the operating system.
+     */
+    public CommandLineException getExecutionException()
+    {
+        return executionException;
+    }
 
     /**
      * Sets the exit code reported by the tool invocation.
      *
      * @param exitCode The exit code reported by the tool invocation.
      */
-    void setExitCode( int exitCode );
+    public void setExitCode( int exitCode )
+    {
+        this.exitCode = exitCode;
+    }
 
     /**
      * Sets the exception that prevented to execute the command line.
      *
      * @param executionException The exception that prevented to execute the 
command line, may be <code>null</code>.
      */
-    void setExecutionException( CommandLineException executionException );
+    public void setExecutionException( CommandLineException executionException 
)
+    {
+        this.executionException = executionException;
+    }
 
     /**
      * Set the commandline used to obtain this result.
      *
      * @param commandline the commandline used to obtain this result
      */
-    void setCommandline( Commandline commandline );
+    public void setCommandline( Commandline commandline )
+    {
+        this.commandline = commandline;
+    }
 }


Reply via email to