@Override public void setLocation(Resource location) { super.setLocation(location); }
@Override public void setLocation(Resource location) { try { location = SpringResourceAdaptor.relative(location, data.getResourceStore()); if (location instanceof SpringResourceAdaptor) { configFile = ((SpringResourceAdaptor) location).getResource(); } } catch (IOException e) { LOGGER.log(Level.WARNING, "Error reading resource " + location, e); } super.setLocation(location); }
@Test public void localPropertiesViaResource() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerBeanDefinition("testBean", genericBeanDefinition(TestBean.class) .addPropertyValue("name", "${my.name}") .getBeanDefinition()); PropertyPlaceholderConfigurer pc = new PropertyPlaceholderConfigurer(); Resource resource = new ClassPathResource("PropertyPlaceholderConfigurerTests.properties", this.getClass()); pc.setLocation(resource); pc.postProcessBeanFactory(bf); }
/** * Gets the property placeholder configurer. * * @return the property placeholder configurer */ @Bean(name = "propertyPlaceholderConfigurer") public static PropertyPlaceholderConfigurer getPropertyPlaceholderConfigurer() { logger.debug("Instantiated propertyPlaceholderConfigurer"); PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); configurer.setLocation(new ClassPathResource("stats.properties")); configurer.setNullValue("NULL"); Properties properties = new Properties(); properties.put("psiprobe.tools.mail.to", "NULL"); properties.put("psiprobe.tools.mail.subjectPrefix", "[PSI Probe]"); configurer.setProperties(properties); configurer.setSystemPropertiesModeName("SYSTEM_PROPERTIES_MODE_OVERRIDE"); return configurer; }
public void setLocation(Resource location) { super.setLocation(location); } }
@Override public void setLocation(Resource location) { table.setResources(new Resource[]{location}); super.setLocation(location); }
@Override public void setLocation(Resource location) { super.setLocation(analyzeLocation(location)); }
@Override public void setLocation(Resource location) { if (StringUtils.isBlank(getSystemPropertyName())) { throw new IllegalArgumentException("Missing value for 'systemPropertyName'."); } Resource locationResource; final String overrideProperty = System.getProperty(getSystemPropertyName()); if (StringUtils.isBlank(overrideProperty)) { locationResource = location; } else if (overrideProperty.startsWith(CLASSPATH)) { locationResource = new ClassPathResource(overrideProperty.substring(CLASSPATH.length())); } else { locationResource = new FileSystemResource(overrideProperty); } super.setLocation(locationResource); }
@Configuration public class PropertiesConfiguration { @Bean public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer( @Value("#{servletContext.contextPath}") String contextPath) throws MalformedURLException { final PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); configurer.setLocation(new UrlResource("file:" + System.getProperty("user.home") + "/" + contextPath + ".properties")); return configurer; } }
public static PropertyPlaceholderConfigurer propConfig() { PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); ppc.setLocation(new ClassPathResource("resources/shore-dal_queries.xml")); return ppc;
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); ResourceLoader resourceLoader = new DefaultResourceLoader(); Resource resource = resourceLoader.getResource("classpath:"+System.getenv("SERVER_TYPE")+"DB.properties"); configurer.setLocation(resource); configurer.postProcessBeanFactory(beanFactory);
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); configurer.setLocation(new ClassPathResource("context.properties")); ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml"}, false); applicationContext.addBeanFactoryPostProcessor(configurer); applicationContext.refresh();
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); ResourceLoader resourceLoader = new DefaultResourceLoader(); Resource resource = resourceLoader.getResource("classpath:localDB.properties"); configurer.setLocation(resource); configurer.postProcessBeanFactory(beanFactory);
protected List getBeanFactoryPostProcessors(String serviceUnitRootPath) { List processors = new ArrayList(); // Property place holder PropertyPlaceholderConfigurer propertyPlaceholder = new PropertyPlaceholderConfigurer(); FileSystemResource propertiesFile = new FileSystemResource(new File(serviceUnitRootPath) + "/" + getXBeanFile() + ".properties"); if (propertiesFile.getFile().exists()) { propertyPlaceholder.setLocation(propertiesFile); processors.add(propertyPlaceholder); } // Parent beans map Map beans = getParentBeansMap(); if (beans != null) { processors.add(new ParentBeanFactoryPostProcessor(beans)); } return processors; }
@Override public void afterPropertiesSet() throws Exception { File properties = new File(config.getConfiguration(EmbeddedBrokerConfiguration.EMBEDDED_BROKER_PROPERTIES_KEY).toString()); if (!properties.isAbsolute() && !properties.isFile()) { // try to resolve as absolute properties = new File(JMSConfiguration.getConfigPathDir(),properties.getPath()); // copy the defaults InputStream inputStream = null; try{ inputStream = defaults.getInputStream(); IOUtils.copy(inputStream, properties); }finally{ if(inputStream!=null){ org.apache.commons.io.IOUtils.closeQuietly(inputStream); } } } final Resource res = new FileSystemResource(properties); super.setLocation(res); // make sure the activemq.base is set to a valuable default final Properties props=new Properties(); props.setProperty("activemq.base", (String)config.getConfiguration("CLUSTER_CONFIG_DIR")); props.setProperty("instanceName", (String)config.getConfiguration("instanceName")); setProperties(props); }
/** * Uses the Spring bean config for dbLoader to get a fully configured * instance. The configuration options may be changed before calling * process. * * @return A fully configured DbLoader. */ public static DbLoader newConfiguredInstance() { //Load the bean factory final URL contextXmlUrl = DbLoaderRunner.class.getResource(DBLOADER_CONTEXT_XML); final XmlBeanFactory beanFactory = new XmlBeanFactory(new UrlResource(contextXmlUrl)); //Decorate the bean factory with the rdbm configuration final PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer(); final URL url = DbLoaderRunner.class.getResource(RDBM_PROPERTIES); cfg.setLocation(new UrlResource(url)); try { cfg.postProcessBeanFactory(beanFactory); } catch (Exception e) { System.err.println("Could not locate properties in the given application context"); } //Get the dbLoader bean final DbLoader loader = (DbLoader)beanFactory.getBean("dbLoader", DbLoader.class); return loader; }
configurer.setLocation(resource);
propertyPlaceholderConfigurer.setLocation((Resource) properties); else if (properties instanceof Properties) propertyPlaceholderConfigurer.setProperties((Properties) properties);
PropertyPlaceholderConfigurer propConfig() { PropertyPlaceholderConfigurer placeholderConfigurer = new PropertyPlaceholderConfigurer(); placeholderConfigurer.setLocation(new ClassPathResource("application_test.properties")); return placeholderConfigurer;