// Tool information
toolInfo = new ToolInfo(TOOL_NAME);
// Create document factory
DocumentFactory documentFactory = DocumentFactory.newInstance();
// Get new config object
monitorConfig = documentFactory.newMonitorConfig();
monitorConfig.init(this.messageList);
// Parse command line arguments
monitorConfig.parseArgs(args);
String logLocation = monitorConfig.getLogLocation();
if (logLocation.indexOf(WSIConstants.PATH_SEPARATOR) > -1)
{
throw new WSIException(
messageList.getMessage(
"config11",
monitorConfig.getLogLocation(),
"The log file location value cannot contain the pass separator character:"));
}
File file = null;
try
{
// Get file object for log file
file = new File(monitorConfig.getLogLocation());
}
catch (Exception e)
{
throw new WSIException(
messageList.getMessage("config07", "Could not get log file location."),
e);
}
// If replace flag is false and file exists, then throw exception
if (file.exists() && !monitorConfig.getReplaceLog())
{
throw new IllegalArgumentException(
messageList.getMessage(
"config08",
monitorConfig.getLogLocation(),
"Log file already exists:"));
}
try
{
// Create output file
log = documentFactory.newLog();
// Set style sheet string
log.setStyleSheetString(
monitorConfig.getAddStyleSheet().getStyleSheetString());
// Get log writer
logWriter = documentFactory.newLogWriter();
logWriter.setWriter(monitorConfig.getLogLocation());
// Write start of log file
logWriter.write(new StringReader(log.getStartXMLString("")));