public void initialize()
throws BrowserLaunchingInitializingException {
try {
URL configUrl = getClass().getResource(configFileName);
if (configUrl == null) {
throw new BrowserLaunchingInitializingException(
"unable to find config file: " + configFileName);
}
StringBuffer potentialBrowserNames = new StringBuffer();
Properties configProps = new Properties();
configProps.load(configUrl.openStream());
String sepChar = configProps.getProperty(PROP_KEY_DELIMITER);
Iterator keysIter = configProps.keySet().iterator();
while (keysIter.hasNext()) {
String key = (String) keysIter.next();
if (key.startsWith(PROP_KEY_BROWSER_PREFIX)) {
SoyLatteBrowserImpl browser = new SoyLatteBrowserImpl(
sepChar,
configProps.getProperty(key));
if (browser.isBrowserAvailable(logger)) {
soylatteBrowsers.put(browser.getBrowserDisplayName(),
browser);
}
else {
if (potentialBrowserNames.length() > 0) {
potentialBrowserNames.append("; ");
}
potentialBrowserNames.append(
browser.getBrowserDisplayName());
}
}
}
if (soylatteBrowsers.size() == 0) {
// no browser installed
throw new BrowserLaunchingInitializingException(
"one of the supported browsers must be installed: "
+ potentialBrowserNames);
}
logger.info(soylatteBrowsers.keySet().toString());
soylatteBrowsers = Collections.unmodifiableMap(soylatteBrowsers);
}
catch (IOException ioex) {
throw new BrowserLaunchingInitializingException(ioex);
}
}