protected static Configuration getConfiguration(String descriptor, SourceResolver resolver,
boolean reloadable, Logger logger)
throws ConfigurationException {
if (descriptor == null) {
throw new ConfigurationException("The form descriptor is not set!");
}
ConfigurationHelper conf = null;
synchronized (XSPFormValidatorHelper.configurations) {
Source source = null;
try {
source = resolver.resolveURI(descriptor);
conf = (ConfigurationHelper) XSPFormValidatorHelper.configurations.get(source.getURI());
if (conf == null || (reloadable && conf.lastModified != source.getLastModified())) {
logger.debug("(Re)Loading " + descriptor);
if (conf == null) {
conf = new ConfigurationHelper();
}
SAXConfigurationHandler builder = new SAXConfigurationHandler();
resolver.toSAX(source, builder);
conf.lastModified = source.getLastModified();
conf.configuration = builder.getConfiguration();
XSPFormValidatorHelper.cacheConfiguration(source.getURI(), conf);
} else {
logger.debug("Using cached configuration for " + descriptor);
}
} catch (Exception e) {
logger.error("Could not configure Database mapping environment", e);
throw new ConfigurationException("Error trying to load configurations for resource: " + source.getURI());
} finally {
resolver.release(source);
}
}