org.apache.maven.shared.utils.cli.javatool
Class AbstractJavaTool<Request extends JavaToolRequest>

java.lang.Object
  extended by org.codehaus.plexus.logging.AbstractLogEnabled
      extended by org.apache.maven.shared.utils.cli.javatool.AbstractJavaTool<Request>
Type Parameters:
Request -
All Implemented Interfaces:
JavaTool<Request>, org.codehaus.plexus.logging.LogEnabled

public abstract class AbstractJavaTool<Request extends JavaToolRequest>
extends org.codehaus.plexus.logging.AbstractLogEnabled
implements JavaTool<Request>

Abstract implementation of a JavaTool.

Since:
0.5
Author:
Tony Chemit

Constructor Summary
protected AbstractJavaTool(String javaToolName)
           
 
Method Summary
protected abstract  Commandline createCommandLine(Request request, String javaToolFile)
          Create the commandline object given the request.
protected  JavaToolResult createResult()
           
protected  StreamConsumer createSystemErrorStreamConsumer(Request request)
           
protected  InputStream createSystemInputStream()
           
protected  StreamConsumer createSystemOutStreamConsumer(Request request)
           
 JavaToolResult execute(Request request)
          Execute the input request and then returns the result of the execution.
protected  JavaToolResult executeCommandLine(Commandline cli, Request request)
           
protected  String findJavaToolExecutable()
           
 String getJavaToolName()
          Return the name of the java tool.
 void setToolchain(org.apache.maven.toolchain.Toolchain toolchain)
          Set an optional tool chain to find out the java tool executable location.
 
Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractJavaTool

protected AbstractJavaTool(String javaToolName)
Method Detail

createCommandLine

protected abstract Commandline createCommandLine(Request request,
                                                 String javaToolFile)
                                          throws JavaToolException
Create the commandline object given the request.

Parameters:
request - User request on the java tool
javaToolFile - Location of the java tool file to use
Returns:
the commandline
Throws:
JavaToolException - if could not create the command line from the request

getJavaToolName

public String getJavaToolName()
Return the name of the java tool. This is exactly the name (without his extension) of the executable to find in the jdk/bin directory.

For example: jarsigner, keytool, javadoc, ...

Specified by:
getJavaToolName in interface JavaTool<Request extends JavaToolRequest>
Returns:
the name of the java tool.

setToolchain

public void setToolchain(org.apache.maven.toolchain.Toolchain toolchain)
Set an optional tool chain to find out the java tool executable location.

Specified by:
setToolchain in interface JavaTool<Request extends JavaToolRequest>
Parameters:
toolchain - optional tool chain to find out the java tool executable location.

execute

public JavaToolResult execute(Request request)
                       throws JavaToolException
Execute the input request and then returns the result of the execution.

If could not create the java tool invocation, a JavaToolException will be thrown.

If execution fails, then the result will have a none-zero JavaToolResult.getExitCode() and his JavaToolResult.getExecutionException() will be filled with the error, otherwise the exist code will be zero.

Specified by:
execute in interface JavaTool<Request extends JavaToolRequest>
Parameters:
request - the request to perform
Returns:
the result of the tool execution
Throws:
JavaToolException - if could not create the java tool invocation

createSystemInputStream

protected InputStream createSystemInputStream()

executeCommandLine

protected JavaToolResult executeCommandLine(Commandline cli,
                                            Request request)

createSystemErrorStreamConsumer

protected StreamConsumer createSystemErrorStreamConsumer(Request request)

createSystemOutStreamConsumer

protected StreamConsumer createSystemOutStreamConsumer(Request request)

createResult

protected JavaToolResult createResult()

findJavaToolExecutable

protected String findJavaToolExecutable()


Copyright © 2002–2015 The Apache Software Foundation. All rights reserved.