hudson.plugins.accurev
Class AccurevLauncher

java.lang.Object
  extended by hudson.plugins.accurev.AccurevLauncher

public final class AccurevLauncher
extends Object

Utility class that knows how to run AccuRev commands and (optionally) have something parse their output.


Nested Class Summary
static interface AccurevLauncher.ICmdOutputParser<TResult,TContext>
          Interface implemented by code that interprets the output of AccuRev commands.
static interface AccurevLauncher.ICmdOutputXmlParser<TResult,TContext>
          Interface implemented by code that interprets the output of AccuRev commands.
static class AccurevLauncher.UnhandledAccurevCommandOutput
          Exception that can be throw if the AccuRev command's output cannot be parsed or is otherwise invalid.
 
Constructor Summary
AccurevLauncher()
           
 
Method Summary
static
<TResult,TContext>
TResult
runCommand(String humanReadableCommandName, hudson.Launcher launcher, hudson.util.ArgumentListBuilder machineReadableCommand, boolean[] masksOrNull, Lock synchronizationLockObjectOrNull, Map<String,String> environmentVariables, hudson.FilePath directoryToRunCommandFrom, hudson.model.TaskListener listenerToLogFailuresTo, Logger loggerToLogFailuresTo, AccurevLauncher.ICmdOutputParser<TResult,TContext> commandOutputParser, TContext commandOutputParserContext)
          Runs a command a parses the output, returning the result of parsing that output.
static boolean runCommand(String humanReadableCommandName, hudson.Launcher launcher, hudson.util.ArgumentListBuilder machineReadableCommand, boolean[] masksOrNull, Lock synchronizationLockObjectOrNull, Map<String,String> environmentVariables, hudson.FilePath directoryToRunCommandFrom, hudson.model.TaskListener listenerToLogFailuresTo, Logger loggerToLogFailuresTo, boolean... optionalFlagToCopyAllOutputToTaskListener)
          Runs a command and returns true if it passed, false if it failed, and logs the errors.
static
<TResult,TContext>
TResult
runCommand(String humanReadableCommandName, hudson.Launcher launcher, hudson.util.ArgumentListBuilder machineReadableCommand, boolean[] masksOrNull, Lock synchronizationLockObjectOrNull, Map<String,String> environmentVariables, hudson.FilePath directoryToRunCommandFrom, hudson.model.TaskListener listenerToLogFailuresTo, Logger loggerToLogFailuresTo, org.xmlpull.v1.XmlPullParserFactory xmlParserFactory, AccurevLauncher.ICmdOutputXmlParser<TResult,TContext> commandOutputParser, TContext commandOutputParserContext)
          As runCommand(String, Launcher, ArgumentListBuilder, boolean[], Lock, Map, FilePath, TaskListener, Logger, ICmdOutputParser, Object) but uses an AccurevLauncher.ICmdOutputXmlParser instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccurevLauncher

public AccurevLauncher()
Method Detail

runCommand

public static boolean runCommand(String humanReadableCommandName,
                                 hudson.Launcher launcher,
                                 hudson.util.ArgumentListBuilder machineReadableCommand,
                                 boolean[] masksOrNull,
                                 Lock synchronizationLockObjectOrNull,
                                 Map<String,String> environmentVariables,
                                 hudson.FilePath directoryToRunCommandFrom,
                                 hudson.model.TaskListener listenerToLogFailuresTo,
                                 Logger loggerToLogFailuresTo,
                                 boolean... optionalFlagToCopyAllOutputToTaskListener)
Runs a command and returns true if it passed, false if it failed, and logs the errors.

Parameters:
humanReadableCommandName - Human-readable text saying what this command is. This appears in the logs if there is a failure.
launcher - Means of executing the command.
machineReadableCommand - The command to be executed.
masksOrNull - Argument for Launcher.ProcStarter.masks(boolean...), or null if not required.
synchronizationLockObjectOrNull - The Lock object to be used to prevent concurrent execution on the same machine, or null if no synchronization is required.
environmentVariables - The environment variables to be passed to the command.
directoryToRunCommandFrom - The direction that the command should be run in.
listenerToLogFailuresTo - One possible place to log failures, or null.
loggerToLogFailuresTo - Another place to log failures, or null.
optionalFlagToCopyAllOutputToTaskListener - Optional: If present and true, all command output will also be copied to the listener if the command is successful.
Returns:
true if the command succeeded.

runCommand

public static <TResult,TContext> TResult runCommand(String humanReadableCommandName,
                                                    hudson.Launcher launcher,
                                                    hudson.util.ArgumentListBuilder machineReadableCommand,
                                                    boolean[] masksOrNull,
                                                    Lock synchronizationLockObjectOrNull,
                                                    Map<String,String> environmentVariables,
                                                    hudson.FilePath directoryToRunCommandFrom,
                                                    hudson.model.TaskListener listenerToLogFailuresTo,
                                                    Logger loggerToLogFailuresTo,
                                                    org.xmlpull.v1.XmlPullParserFactory xmlParserFactory,
                                                    AccurevLauncher.ICmdOutputXmlParser<TResult,TContext> commandOutputParser,
                                                    TContext commandOutputParserContext)
As runCommand(String, Launcher, ArgumentListBuilder, boolean[], Lock, Map, FilePath, TaskListener, Logger, ICmdOutputParser, Object) but uses an AccurevLauncher.ICmdOutputXmlParser instead.

Parameters:
xmlParserFactory - The XmlPullParserFactory to be used to create the parser. If this is null then no command will be executed and the function will return null immediately.
Returns:
See above.

runCommand

public static <TResult,TContext> TResult runCommand(String humanReadableCommandName,
                                                    hudson.Launcher launcher,
                                                    hudson.util.ArgumentListBuilder machineReadableCommand,
                                                    boolean[] masksOrNull,
                                                    Lock synchronizationLockObjectOrNull,
                                                    Map<String,String> environmentVariables,
                                                    hudson.FilePath directoryToRunCommandFrom,
                                                    hudson.model.TaskListener listenerToLogFailuresTo,
                                                    Logger loggerToLogFailuresTo,
                                                    AccurevLauncher.ICmdOutputParser<TResult,TContext> commandOutputParser,
                                                    TContext commandOutputParserContext)
Runs a command a parses the output, returning the result of parsing that output. Returns null if the command failed or if parsing failed. Failures are logged.

Type Parameters:
TResult - The type of the result returned by the parser.
TContext - The type of data to be passed to the parser. Can be Void if no result is needed.
Parameters:
humanReadableCommandName - Human-readable text saying what this command is. This appears in the logs if there is a failure.
launcher - Means of executing the command.
machineReadableCommand - The command to be executed.
masksOrNull - Argument for Launcher.ProcStarter.masks(boolean...), or null if not required.
synchronizationLockObjectOrNull - The Lock object to be used to prevent concurrent execution on the same machine, or null if no synchronization is required.
environmentVariables - The environment variables to be passed to the command.
directoryToRunCommandFrom - The direction that the command should be run in.
listenerToLogFailuresTo - One possible place to log failures, or null.
loggerToLogFailuresTo - Another place to log failures, or null.
commandOutputParser - The code that will parse the command's output (if the command succeeds).
commandOutputParserContext - Data to be passed to the parser.
Returns:
The data returned by the AccurevLauncher.ICmdOutputParser, or null if an error occurred.


Copyright © 2004-2013. All Rights Reserved.