List of usage examples for org.springframework.beans.factory.config PropertiesFactoryBean afterPropertiesSet
@Override public final void afterPropertiesSet() throws IOException
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(); return props; }
From source file:com.zekke.webapp.config.MainConfig.java
/** * Creates a new Properties.// w ww.ja v a2 s . c om * * @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:edu.harvard.i2b2.fr.util.FRUtil.java
/** * Load application property file into memory *//* w w w . j ava 2s . co 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:edu.harvard.i2b2.pm.util.PMUtil.java
/** * Load application property file into memory *//* w w w.j ava2 s .c om*/ 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 *//*from w w w . jav a2 s . c om*/ 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 w w. j a v a 2s . 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:org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.java
/** * The {@link MessageSourceAccessor} to provide messages for {@link ResourceDescription}s being rendered. * //from w w w . ja v a 2s . com * @return */ @Bean public MessageSourceAccessor resourceDescriptionMessageSourceAccessor() { try { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("rest-default-messages.properties")); propertiesFactoryBean.afterPropertiesSet(); ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setBasename("classpath:rest-messages"); messageSource.setCommonMessages(propertiesFactoryBean.getObject()); messageSource.setDefaultEncoding("UTF-8"); return new MessageSourceAccessor(messageSource); } catch (Exception o_O) { throw new BeanCreationException("resourceDescriptionMessageSourceAccessor", "", o_O); } }
From source file:org.jahia.test.framework.JahiaWebInitializer.java
@Override public void initialize(GenericWebApplicationContext webAppContext) { try {/*w w w. j ava 2s . c o m*/ Resource[] resources = webAppContext .getResources("classpath*:org/jahia/config/jahiaunittest.properties"); PropertiesFactoryBean propertiesFactory = new PropertiesFactoryBean(); propertiesFactory.setLocations(resources); propertiesFactory.afterPropertiesSet(); Properties properties = propertiesFactory.getObject(); String jackrabbitHome = (String) properties.get("jahia.jackrabbit.home"); if (jackrabbitHome != null) { jackrabbitHome = webAppContext.getResource(jackrabbitHome).getURL().getPath(); File repoHome = new File(jackrabbitHome); if (!repoHome.exists()) { repoHome.mkdirs(); } if (resources[0] != null && ResourceUtils.isJarURL(resources[0].getURL())) { URL jarUrl = ResourceUtils.extractJarFileURL(resources[0].getURL()); try { new JahiaArchiveFileHandler(jarUrl.getPath()).unzip("./target/test-repo", new PathFilter() { @Override public boolean accept(String path) { // TODO Auto-generated method stub return path.startsWith("WEB-INF"); } }); } catch (JahiaException e) { logger.error("Unable to extract JAR"); } } else if (resources[0] != null) { FileUtils.copyDirectory( new File(StringUtils.substringBefore(resources[0].getURI().getPath(), "org"), "WEB-INF"), new File("./target/test-repo", "WEB-INF")); } } } catch (IOException e) { } }