List of usage examples for org.springframework.beans.factory.config PropertiesFactoryBean setLocation
public void setLocation(Resource location)
From source file:com.zekke.webapp.config.TestConfig.java
@Bean public static PropertiesFactoryBean configProperties(ResourceLoader resourceLoader) throws IOException { PropertiesFactoryBean props = new PropertiesFactoryBean(); props.setLocation(resourceLoader.getResource(CONFIG_PROPERTIES_URI)); props.afterPropertiesSet();/*from w w w . j a va2s. co m*/ return props; }
From source file:com.zekke.webapp.config.MainConfig.java
/** * Creates a new Properties./*w w w.j ava 2s. c o m*/ * * @param resourceLoader any ResourceLoader. * @return a Properties. * @throws IOException if the properties file is not found in * {@link #CONFIG_PROPERTIES_URI}. */ @Bean public static PropertiesFactoryBean configProperties(ResourceLoader resourceLoader) throws IOException { PropertiesFactoryBean props = new PropertiesFactoryBean(); props.setLocation(resourceLoader.getResource(CONFIG_PROPERTIES_URI)); props.afterPropertiesSet(); return props; }
From source file:com.orange.clara.pivotaltrackermirror.config.QuartzConfig.java
@Bean public Properties quartzProperties() throws IOException { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); propertiesFactoryBean.afterPropertiesSet(); return propertiesFactoryBean.getObject(); }
From source file:info.naiv.lab.java.tool.sqlite.exporter.AppSettings.java
/** * * @return//from w w w . j a v a 2 s .c o m */ @Bean(name = "externalProperties") public PropertiesFactoryBean propertiesFactoryBean() { Properties p = new Properties(); setPropertyIfNotBlank(p, "datasource.url", sourceUrl); setPropertyIfNotBlank(p, "datasource.schema", sourceSchema); setPropertyIfNotBlank(p, "datasource.username", sourceUsername); setPropertyIfNotBlank(p, "datasource.password", sourcePassword); setPropertyIfNotBlank(p, "jdbc.driver.directory", jdbcDriverDirectory); PropertiesFactoryBean bean = new ResolvablePropertiesFactoryBean(); bean.setIgnoreResourceNotFound(true); bean.setLocation(new FileSystemResource(propertyLocation)); bean.setProperties(p); bean.setLocalOverride(true); return bean; }
From source file:edu.harvard.i2b2.fr.util.FRUtil.java
/** * Load application property file into memory */// www . j a v a 2 s . c o m private String getPropertyValue(String propertyName) throws I2B2Exception { if (appProperties == null) { //read application directory property file loadProperties = ServiceLocator.getProperties(APPLICATION_DIRECTORY_PROPERTIES_FILENAME); //read application directory property String appDir = loadProperties.getProperty(APPLICATIONDIR_PROPERTIES); if (appDir == null) { throw new I2B2Exception("Could not find " + APPLICATIONDIR_PROPERTIES + "from " + APPLICATION_DIRECTORY_PROPERTIES_FILENAME); } String appPropertyFile = appDir + "/" + APPLICATION_PROPERTIES_FILENAME; try { FileSystemResource fileSystemResource = new FileSystemResource(appPropertyFile); PropertiesFactoryBean pfb = new PropertiesFactoryBean(); pfb.setLocation(fileSystemResource); pfb.afterPropertiesSet(); appProperties = (Properties) pfb.getObject(); } catch (IOException e) { throw new I2B2Exception("Application property file(" + appPropertyFile + ") missing entries or not loaded properly"); } if (appProperties == null) { throw new I2B2Exception("Application property file(" + appPropertyFile + ") missing entries or not loaded properly"); } } String propertyValue = appProperties.getProperty(propertyName); if ((propertyValue != null) && (propertyValue.trim().length() > 0)) { ; } else { throw new I2B2Exception("Application property file(" + APPLICATION_PROPERTIES_FILENAME + ") missing " + propertyName + " entry"); } return propertyValue; }
From source file:dubbo.spring.javaconfig.DatabaseConfig.java
/** * ??//www . j a va 2 s . c o m * @return */ @Bean public PropertiesFactoryBean dbConfig() { PropertiesFactoryBean dbConfig = new PropertiesFactoryBean(); dbConfig.setLocation(new ClassPathResource("database.properties")); return dbConfig; }
From source file:dubbo.spring.javaconfig.DatabaseConfig.java
/** * hibernate ? envers ?/*from www . ja v a 2s . c om*/ * @return */ @Bean public PropertiesFactoryBean hibernateConfig() { PropertiesFactoryBean dbConfig = new PropertiesFactoryBean(); dbConfig.setLocation(new ClassPathResource("hibernate.properties")); return dbConfig; }
From source file:edu.harvard.i2b2.pm.util.PMUtil.java
/** * Load application property file into memory *//*from w w w. j a va 2s. c o m*/ private String getPropertyValue(String propertyName) throws I2B2Exception { if (appProperties == null) { //read application directory property file Properties loadProperties = ServiceLocator.getProperties(APPLICATION_DIRECTORY_PROPERTIES_FILENAME); //read application directory property String appDir = loadProperties.getProperty(APPLICATIONDIR_PROPERTIES); if (appDir == null) { throw new I2B2Exception("Could not find " + APPLICATIONDIR_PROPERTIES + "from " + APPLICATION_DIRECTORY_PROPERTIES_FILENAME); } String appPropertyFile = appDir + "/" + APPLICATION_PROPERTIES_FILENAME; try { FileSystemResource fileSystemResource = new FileSystemResource(appPropertyFile); PropertiesFactoryBean pfb = new PropertiesFactoryBean(); pfb.setLocation(fileSystemResource); pfb.afterPropertiesSet(); appProperties = (Properties) pfb.getObject(); } catch (IOException e) { throw new I2B2Exception("Application property file(" + appPropertyFile + ") missing entries or not loaded properly"); } if (appProperties == null) { throw new I2B2Exception("Application property file(" + appPropertyFile + ") missing entries or not loaded properly"); } } String propertyValue = appProperties.getProperty(propertyName); if ((propertyValue != null) && (propertyValue.trim().length() > 0)) { ; } else { throw new I2B2Exception("Application property file(" + APPLICATION_PROPERTIES_FILENAME + ") missing " + propertyName + " entry"); } return propertyValue; }
From source file:edu.harvard.i2b2.ontology.util.OntologyUtil.java
/** * Load application property file into memory */// w w w. jav a 2 s. co m private String getPropertyValue(String propertyName) throws I2B2Exception { if (appProperties == null) { // read application directory property file Properties loadProperties = ServiceLocator.getProperties(APPLICATION_DIRECTORY_PROPERTIES_FILENAME); // read application directory property String appDir = loadProperties.getProperty(APPLICATIONDIR_PROPERTIES); if (appDir == null) { throw new I2B2Exception("Could not find " + APPLICATIONDIR_PROPERTIES + "from " + APPLICATION_DIRECTORY_PROPERTIES_FILENAME); } String appPropertyFile = appDir + "/" + APPLICATION_PROPERTIES_FILENAME; try { FileSystemResource fileSystemResource = new FileSystemResource(appPropertyFile); PropertiesFactoryBean pfb = new PropertiesFactoryBean(); pfb.setLocation(fileSystemResource); pfb.afterPropertiesSet(); appProperties = (Properties) pfb.getObject(); } catch (IOException e) { throw new I2B2Exception("Application property file(" + appPropertyFile + ") missing entries or not loaded properly"); } if (appProperties == null) { throw new I2B2Exception("Application property file(" + appPropertyFile + ") missing entries or not loaded properly"); } } String propertyValue = appProperties.getProperty(propertyName); if ((propertyValue != null) && (propertyValue.trim().length() > 0)) { ; } else { throw new I2B2Exception("Application property file(" + APPLICATION_PROPERTIES_FILENAME + ") missing " + propertyName + " entry"); } return propertyValue; }
From source file:edu.harvard.i2b2.crc.loader.util.CRCLoaderUtil.java
/** * Load application property file into memory *///from w ww .j a v a2s . c om private String getPropertyValue(String propertyName) throws I2B2Exception { if (appProperties == null) { // read application directory property file loadProperties = ServiceLocator.getProperties(APPLICATION_DIRECTORY_PROPERTIES_FILENAME); // read application directory property String appDir = loadProperties.getProperty(APPLICATIONDIR_PROPERTIES); if (appDir == null) { throw new I2B2Exception("Could not find " + APPLICATIONDIR_PROPERTIES + "from " + APPLICATION_DIRECTORY_PROPERTIES_FILENAME); } String appPropertyFile = appDir + "/" + APPLICATION_PROPERTIES_FILENAME; try { FileSystemResource fileSystemResource = new FileSystemResource(appPropertyFile); PropertiesFactoryBean pfb = new PropertiesFactoryBean(); pfb.setLocation(fileSystemResource); pfb.afterPropertiesSet(); appProperties = (Properties) pfb.getObject(); } catch (IOException e) { throw new I2B2Exception("Application property file(" + appPropertyFile + ") missing entries or not loaded properly"); } if (appProperties == null) { throw new I2B2Exception("Application property file(" + appPropertyFile + ") missing entries or not loaded properly"); } } String propertyValue = appProperties.getProperty(propertyName); if ((propertyValue != null) && (propertyValue.trim().length() > 0)) { ; } else { throw new I2B2Exception("Application property file(" + APPLICATION_PROPERTIES_FILENAME + ") missing " + propertyName + " entry"); } return propertyValue; }