{
// Get new config reader
MonitorConfigReader monitorConfigReader = new MonitorConfigReaderImpl();
// Monitor config object which will be merged after all of the input parms are processed
MonitorConfig monitorConfigFromArgs = null;
// If no input arguments, then throw exception
if (args.length == 0)
{
// ADD:
throw new IllegalArgumentException(
getMessage("usage01", Monitor.USAGE_MESSAGE));
}
// Parse the command line arguments to locate the config file option (if it was specified)
for (int argCount = 0; argCount < args.length; argCount++)
{
// -configFile
if ((args[argCount].equalsIgnoreCase("-config"))
|| (args[argCount].equals("-c")))
{
argCount++;
monitorConfigFromArgs =
monitorConfigReader.readMonitorConfig(args[argCount]);
}
}
// If config file was not specified, then create analyzer config object
if (monitorConfigFromArgs == null)
{
monitorConfigFromArgs = new MonitorConfigImpl();
monitorConfigFromArgs.init(this.messageList);
}
// Parse all of the command line arguments
for (int argCount = 0; argCount < args.length; argCount++)
{
// -configFile
if ((args[argCount].equalsIgnoreCase("-config"))
|| (args[argCount].equals("-c")))
{
// Skip this option since it was already processed
argCount++;
}
// -comment
else if (
(args[argCount].equalsIgnoreCase("-comment"))
|| (args[argCount].equals("-C")))
{
argCount++;
Comment comment = new CommentImpl();
comment.setText(args[argCount]);
monitorConfigFromArgs.setComment(comment);
}
// -logFile
else if (
(args[argCount].equalsIgnoreCase("-logFile"))
|| (args[argCount].equals("-l")))
{
argCount++;
monitorConfigFromArgs.setLogLocation(args[argCount]);
}
// -replace
else if (
(args[argCount].equalsIgnoreCase("-replace"))
|| (args[argCount].equals("-r")))
{
argCount++;
monitorConfigFromArgs.setReplaceLog(
Boolean.valueOf(args[argCount]).booleanValue());
}
// -logDuration
else if (
(args[argCount].equalsIgnoreCase("-logDuration"))
|| (args[argCount].equals("-d")))
{
argCount++;
monitorConfigFromArgs.setLogDuration(
Integer.valueOf(args[argCount]).intValue());
}
// -timeout
else if (
(args[argCount].equalsIgnoreCase("-timeout"))
|| (args[argCount].equals("-t")))
{
argCount++;
monitorConfigFromArgs.setTimeout(
Integer.valueOf(args[argCount]).intValue());
}
// -manInTheMiddle
else if (
(args[argCount].equalsIgnoreCase("-manInTheMiddle"))
|| (args[argCount].equals("-m")))
{
ManInTheMiddle manInTheMiddle = null;
// Increment arg count
argCount++;
// Get the man-in-the-middle object
if ((manInTheMiddle = monitorConfigFromArgs.getManInTheMiddle())
== null)
manInTheMiddle = new ManInTheMiddleImpl();
// ADD: Check for correct number of remaining args
// Create redirect
Redirect redirect = new RedirectImpl();
// Get the redirect values
redirect.setListenPort(Integer.valueOf(args[argCount++]).intValue());
redirect.setHost(args[argCount++]);
redirect.setMaxConnections(
Integer.valueOf(args[argCount++]).intValue());
redirect.setReadTimeoutSeconds(
Integer.valueOf(args[argCount++]).intValue());
// Add redirect
manInTheMiddle.addRedirect(redirect);
// Set the man-in-the-middle
monitorConfigFromArgs.setManInTheMiddle(manInTheMiddle);
}
// -verbose
else if (
(args[argCount].equalsIgnoreCase("-verbose"))
|| (args[argCount].equals("-v")))
{
argCount++;
//monitorConfigFromArgs.setVerboseOption(Boolean.valueOf(args[argCount]).booleanValue());
monitorConfigFromArgs.setVerboseOption(true);
}
// -GUI
else if (args[argCount].equalsIgnoreCase("-GUI"))
{
// Ignore -GUI option
}
else
{
throw new IllegalArgumentException(
getMessage(
"config01",
args[argCount],
"The specified option is not supported."));
}
}
// If addStyleSheet was not specified, then create a comment version of it
if (monitorConfigFromArgs.getAddStyleSheet() == null)
{
AddStyleSheet addStyleSheet = new AddStyleSheetImpl();
addStyleSheet.setHref(WSIConstants.DEFAULT_LOG_XSL);
addStyleSheet.setType(WSIConstants.DEFAULT_XSL_TYPE);
addStyleSheet.setComment(true);
monitorConfigFromArgs.setAddStyleSheet(addStyleSheet);
}
// Merge config info into this object
setConfig(monitorConfigFromArgs);