List of usage examples for org.springframework.beans.factory.config PropertyPlaceholderConfigurer setLocations
public void setLocations(Resource... locations)
From source file:stormy.pythian.service.spring.PyhtianProperties.java
@Bean public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer(); propertyPlaceholderConfigurer.setLocations(new Resource[] { // new ClassPathResource("redis-config.properties"), // new ClassPathResource("pythian-config.properties") // });/*from w ww .j a v a2s . co m*/ propertyPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(false); return propertyPlaceholderConfigurer; }
From source file:dk.nsi.minlog.export.config.ApplicationRootConfig.java
@Bean public static PropertyPlaceholderConfigurer configuration() { final PropertyPlaceholderConfigurer props = new PropertyPlaceholderConfigurer(); props.setLocations(new Resource[] { new ClassPathResource("default.properties"), new FileSystemResource(getProperty("jboss.server.config.url") + "minlog." + getProperty("user.name") + ".properties"), new ClassPathResource("minlog." + getProperty("user.name") + ".properties"), new ClassPathResource("jdbc.default.properties"), new FileSystemResource(getProperty("jboss.server.config.url") + "jdbc." + getProperty("user.name") + ".properties"), new ClassPathResource("jdbc." + getProperty("user.name") + ".properties"), new FileSystemResource(getProperty("user.home") + "/.minlog/passwords.properties") }); props.setIgnoreResourceNotFound(true); props.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE); return props; }
From source file:com.iopr.DBResource.java
@Bean public static PropertyPlaceholderConfigurer properties() { PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); Resource[] resources = new ClassPathResource[] { new ClassPathResource("db.properties") }; ppc.setLocations(resources); ppc.setIgnoreUnresolvablePlaceholders(true); return ppc;/*from ww w.j a v a 2 s .co m*/ }
From source file:com.alejandroszlv.mock.repository.config.RepositoryConfig.java
@Bean public static PropertyPlaceholderConfigurer properties() { PropertyPlaceholderConfigurer properties = new PropertyPlaceholderConfigurer(); ClassPathResource[] resources = new ClassPathResource[] { new ClassPathResource("db.properties") }; properties.setLocations(resources); properties.setIgnoreUnresolvablePlaceholders(true); return properties; }
From source file:com.miserablemind.butter.bootstrap.RootContext.java
/** * PropertyPlaceholderConfigurer is required to make {@code @Value} annotations work. * {@code @Value} annotations are used to wire data from .properties files. * * @return {@link PropertyPlaceholderConfigurer}. */// www. j a v a 2 s .c om @Bean public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); Resource[] propertiesFiles = new Resource[] { new ClassPathResource("system.properties"), new ClassPathResource("butterApp/butterApp.properties") }; configurer.setLocations(propertiesFiles); return configurer; }
From source file:org.pegadi.webapp.spring.PropertyReplacer.java
public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException { ServletContextResourceLoader loader = new ServletContextResourceLoader(servletContext); Properties properties = new Properties(); File file = (File) servletContext.getAttribute(DataDirectoryPropertyReplacer.SERVLET_CONTEXT_ATTR); properties.setProperty("dataDir", file.getAbsolutePath()); List<Resource> resources = new ArrayList<Resource>(); resources.add(loader.getResource("/WEB-INF/pegadi.conf")); /* Check wether dataDir/pegadi.conf exist. If it does add it as a location * Also add /WEB-INF/pegadi.conf, so that if the file doesn't exist use default values *//*from w ww. j ava2 s . c o m*/ File configFile = new File(file.getAbsolutePath(), "pegadi.conf"); if (configFile.exists()) { resources.add(loader.getResource("file:" + configFile.getAbsolutePath())); } PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); configurer.setLocations(resources.toArray(new Resource[] {})); configurer.setProperties(properties); configurer.postProcessBeanFactory(configurableListableBeanFactory); }
From source file:no.dusken.common.plugin.spring.PropertyReplacer.java
public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException { ServletContextResourceLoader loader = new ServletContextResourceLoader(servletContext); Properties properties = new Properties(); File file = (File) servletContext.getAttribute(DataDirectoryPropertyReplacer.SERVLET_CONTEXT_ATTR); properties.setProperty("dataDir", file.getAbsolutePath()); List<Resource> resources = new ArrayList<Resource>(); resources.add(loader.getResource("/WEB-INF/" + filename)); /* Check whether dataDir/common.conf exist. If it does add it as a location * Also add /WEB-INF/common.conf, so that if the file doesn't exist use default values */// w w w .j av a 2 s. co m File configFile = new File(file.getAbsolutePath(), filename); if (configFile.exists()) { resources.add(loader.getResource("file:" + configFile.getAbsolutePath())); } PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); configurer.setLocations(resources.toArray(new Resource[resources.size()])); configurer.setProperties(properties); configurer.postProcessBeanFactory(configurableListableBeanFactory); }
From source file:com.thinkbiganalytics.metadata.sla.TestConfiguration.java
@Bean public PropertyPlaceholderConfigurer jiraPropertiesConfigurer() { PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); configurer.setLocations(new ClassPathResource("/conf/sla.email.properties")); configurer.setIgnoreUnresolvablePlaceholders(true); configurer.setIgnoreResourceNotFound(true); return configurer; }
From source file:org.alfresco.repo.management.subsystems.LegacyConfigPostProcessor.java
@SuppressWarnings("unchecked") public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { try {//from w ww. j ava 2 s . c o m // Look up the global-properties bean and its locations list MutablePropertyValues globalProperties = beanFactory .getBeanDefinition(LegacyConfigPostProcessor.BEAN_NAME_GLOBAL_PROPERTIES).getPropertyValues(); PropertyValue pv = globalProperties.getPropertyValue(LegacyConfigPostProcessor.PROPERTY_LOCATIONS); Collection<Object> globalPropertyLocations; Object value; // Use the locations list if there is one, otherwise associate a new empty list if (pv != null && (value = pv.getValue()) != null && value instanceof Collection) { globalPropertyLocations = (Collection<Object>) value; } else { globalPropertyLocations = new ManagedList(10); globalProperties.addPropertyValue(LegacyConfigPostProcessor.PROPERTY_LOCATIONS, globalPropertyLocations); } // Move location paths added to repository-properties MutablePropertyValues repositoryProperties = processLocations(beanFactory, globalPropertyLocations, LegacyConfigPostProcessor.BEAN_NAME_REPOSITORY_PROPERTIES, new String[] { "classpath:alfresco/version.properties" }); // Fix up additional properties to enforce correct order of precedence repositoryProperties.addPropertyValue("ignoreUnresolvablePlaceholders", Boolean.TRUE); repositoryProperties.addPropertyValue("localOverride", Boolean.FALSE); repositoryProperties.addPropertyValue("valueSeparator", null); repositoryProperties.addPropertyValue("systemPropertiesModeName", "SYSTEM_PROPERTIES_MODE_NEVER"); // Move location paths added to hibernateConfigProperties MutablePropertyValues hibernateProperties = processLocations(beanFactory, globalPropertyLocations, LegacyConfigPostProcessor.BEAN_NAME_HIBERNATE_PROPERTIES, new String[] { "classpath:alfresco/domain/hibernate-cfg.properties", "classpath*:alfresco/enterprise/cache/hibernate-cfg.properties" }); // Fix up additional properties to enforce correct order of precedence hibernateProperties.addPropertyValue("localOverride", Boolean.TRUE); // Because Spring gets all post processors in one shot, the bean may already have been created. Let's try to // fix it up! PropertyPlaceholderConfigurer repositoryConfigurer = (PropertyPlaceholderConfigurer) beanFactory .getSingleton(LegacyConfigPostProcessor.BEAN_NAME_REPOSITORY_PROPERTIES); if (repositoryConfigurer != null) { // Reset locations list repositoryConfigurer.setLocations(null); // Invalidate cached merged bean definitions ((BeanDefinitionRegistry) beanFactory).registerBeanDefinition( LegacyConfigPostProcessor.BEAN_NAME_REPOSITORY_PROPERTIES, beanFactory.getBeanDefinition(LegacyConfigPostProcessor.BEAN_NAME_REPOSITORY_PROPERTIES)); // Reconfigure the bean according to its new definition beanFactory.configureBean(repositoryConfigurer, LegacyConfigPostProcessor.BEAN_NAME_REPOSITORY_PROPERTIES); } } catch (NoSuchBeanDefinitionException e) { // Ignore and continue } }