* set to 1 second to prevent excessive date stamp checking.
*/
private void loadConfiguration() throws ConfigurationException
{
//Properties from system properties
CompositeConfiguration compositeConfig = new CompositeConfiguration();
compositeConfig.addConfiguration(new SystemConfiguration());
//Properties from file
PropertiesConfiguration propConfig = null;
final String filename = System.getProperty("juddi.propertiesFile");
if (filename != null)
{
propConfig = new PropertiesConfiguration(filename);
} else {
propConfig = new PropertiesConfiguration(JUDDI_PROPERTIES);
}
URL url = ClassUtil.getResource(JUDDI_PROPERTIES, this.getClass());
log.info("Reading from properties file: " + url);
long refreshDelay = propConfig.getLong(Property.JUDDI_CONFIGURATION_RELOAD_DELAY, 1000l);
log.debug("Setting refreshDelay to " + refreshDelay);
FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileChangedReloadingStrategy();
fileChangedReloadingStrategy.setRefreshDelay(refreshDelay);
propConfig.setReloadingStrategy(fileChangedReloadingStrategy);
compositeConfig.addConfiguration(propConfig);
Properties properties = new Properties();
if ("Hibernate".equals(propConfig.getString(Property.PERSISTENCE_PROVIDER))) {
if (propConfig.containsKey(Property.DATASOURCE))
properties.put("hibernate.connection.datasource",propConfig.getString(Property.DATASOURCE));
if (propConfig.containsKey(Property.HBM_DDL_AUTO))
properties.put("hibernate.hbm2ddl.auto",propConfig.getString(Property.HBM_DDL_AUTO));
if (propConfig.containsKey(Property.DEFAULT_SCHEMA))
properties.put("hibernate.default_schema",propConfig.getString(Property.DEFAULT_SCHEMA));
if (propConfig.containsKey(Property.HIBERNATE_DIALECT))
properties.put("hibernate.dialect",propConfig.getString(Property.HIBERNATE_DIALECT));
}
// initialize the entityManagerFactory.
PersistenceManager.initializeEntityManagerFactory(propConfig.getString(Property.JUDDI_PERSISTENCEUNIT_NAME), properties);
// Properties from the persistence layer
MapConfiguration persistentConfig = new MapConfiguration(getPersistentConfiguration(compositeConfig));
compositeConfig.addConfiguration(persistentConfig);
//Making the new configuration globally accessible.
config = compositeConfig;
}