List of usage examples for org.apache.commons.configuration PropertiesConfiguration setReloadingStrategy
public void setReloadingStrategy(ReloadingStrategy strategy)
From source file:pt.spms.epsos.main.MigrateProperties.java
/** * This method will process the properties and insert them in the database, * based on the specified properties file name. * * @param epsosPropsFile the properties file name. * @throws ConfigurationException if the properties file reading wen wrong. *///w w w . j ava2s. c o m private static void processProperties(final String epsosPropsFile) throws ConfigurationException, FileNotFoundException, IOException { LOGGER.info("READING CONFIGURATION FILE FROM: " + epsosPropsFile); File propsFile = new File(epsosPropsFile); processCommaProperties(propsFile, epsosPropsFile); propsFile = new File(epsosPropsFile); final PropertiesConfiguration config = new PropertiesConfiguration(); config.setReloadingStrategy(new FileChangedReloadingStrategy()); final Session session = HibernateUtil.getSessionFactory().openSession(); LOGGER.info("INSERTING PROPERTIES INTO DATABASE..."); session.beginTransaction(); final Iterator it = config.getKeys(); while (it.hasNext()) { final String key = (String) it.next(); final String value = (String) config.getString(key); LOGGER.info("INSERTING: { KEY: " + key + ", VALUE: " + value + " }"); final Property p = new Property(key, value); session.save(p); } session.getTransaction().commit(); session.close(); }