log.info("Initializing Dialog SCXML Implementation");
}
// Set up to parse our specified configuration resources and cache the results
boolean didDefault = false;
ConfigurationParser parser = new ConfigurationParser();
parser.setDialogs(new HashMap());
// Parse implicitly specified resources embedded in JAR files
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
loader = this.getClass().getClassLoader();
}
try {
Enumeration resources = loader.getResources(EMBEDDED_CONFIGURATION_RESOURCE);
while (resources.hasMoreElements()) {
URL resource = (URL) resources.nextElement();
if (log.isDebugEnabled()) {
log.debug("Parsing configuration resource '"
+ resource + "'");
}
parser.setResource(resource);
parser.parse();
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new FacesException(e);
}
// Parse explicitly specified resources
String resources =
event.getServletContext().getInitParameter(Globals.CONFIGURATION);
if (resources == null) {
resources = "";
}
int comma = 0;
String path = null;
try {
while (true) {
comma = resources.indexOf(",");
if (comma < 0) {
path = resources.trim();
resources = "";
} else {
path = resources.substring(0, comma).trim();
resources = resources.substring(comma + 1);
}
if (path.length() < 1) {
break;
}
URL resource = event.getServletContext().getResource(path);
if (log.isDebugEnabled()) {
log.debug("Parsing configuration resource '"
+ resource + "'");
}
parser.setResource(resource);
parser.parse();
if (DEFAULT_CONFIGURATION_RESOURCE.equals(path)) {
didDefault = true;
}
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new FacesException(e);
}
// Parse the default configuration resource if it exists and has not
// already been parsed
if (!didDefault) {
try {
URL resource =
event.getServletContext().getResource(DEFAULT_CONFIGURATION_RESOURCE);
if (resource != null) {
if (log.isDebugEnabled()) {
log.debug("Parsing configuration resource '"
+ resource + "'");
}
parser.setResource(resource);
parser.parse();
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new FacesException(e);
}
}
// Cache the results in application scope
Map dialogs = parser.getDialogs();
if (dialogs.size() == 0) {
if (log.isWarnEnabled()) {
log.warn("No dialog configuration information present. No default configuration found at: "
+ DEFAULT_CONFIGURATION_RESOURCE + ". No embedded configuration found at: "