public void initialize()
throws BrowserLaunchingInitializingException {
try {
URL configUrl = getClass().getResource(CONFIGFILE_WINDOWS);
if (configUrl == null) {
throw new BrowserLaunchingInitializingException(
"unable to find config file: " + CONFIGFILE_WINDOWS);
}
Properties configProps = new Properties();
configProps.load(configUrl.openStream());
// get sep char
String sepChar = configProps.getProperty(PROP_KEY_DELIMITER);
// load different types of browsers
Iterator keysIter = configProps.keySet().iterator();
while (keysIter.hasNext()) {
String key = (String) keysIter.next();
if (key.startsWith(PROP_KEY_BROWSER_PREFIX)) {
WindowsBrowser winBrowser = new WindowsBrowser(
sepChar,
configProps.getProperty(key));
browsersToCheck.add(winBrowser);
}
}
// load the type of windows based on the windows key
String windowsConfigStr = configProps.getProperty(
windowsKey,
null);
if (windowsConfigStr == null) {
throw new BrowserLaunchingInitializingException(
windowsKey + " is not a valid property");
}
String[] winConfigItems = windowsConfigStr.split(sepChar);
commandsDefaultBrowser = winConfigItems[0];
commandsTargettedBrowser = winConfigItems[1];
Boolean boolVal = new Boolean(winConfigItems[2]);
useRegistry = boolVal.booleanValue();
// check for override of useRegistry from system prop
// need to explicitly check BOTH values to filter out
// invalid prop values
String propValue = System.getProperty(
IBrowserLaunching.WINDOWS_BROWSER_DISC_POLICY_PROPERTY,
null);
if (IBrowserLaunching.WINDOWS_BROWSER_DISC_POLICY_DISK.equals(
propValue)) {
useRegistry = false;
}
else if (IBrowserLaunching.WINDOWS_BROWSER_DISC_POLICY_REGISTRY.
equals(propValue)) {
useRegistry = true;
}
if (logger.isDebugEnabled()) {
logger.debug("Browser discovery policy property value=" +
(propValue == null ? "null" : propValue));
logger.debug("useRegistry=" + Boolean.toString(useRegistry));
}
// get info for checking Program Files folder
programFilesFolderTemplate = configProps.getProperty(
"program.files.template",
null);
driveLetters = configProps.getProperty(
"drive.letters",
null);
// set brwosersToCheck to a non-modifiable list
browsersToCheck = Collections.unmodifiableList(browsersToCheck);
}
catch (IOException ioex) {
throw new BrowserLaunchingInitializingException(ioex);
}
}