use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project tutorials by eugenp.
the class PropertiesWithPlaceHolderConfigurer method propertyConfigurer.
@Bean
public PropertyPlaceholderConfigurer propertyConfigurer() {
final PropertyPlaceholderConfigurer props = new PropertyPlaceholderConfigurer();
props.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_FALLBACK);
return props;
}
use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project tutorials by eugenp.
the class ChildConfig2 method configurer.
@Bean
public static PropertyPlaceholderConfigurer configurer() {
final PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
ppc.setLocations(new ClassPathResource("child.properties"));
return ppc;
}
use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project symmetric-ds by JumpMind.
the class ClientSymmetricEngine method init.
@Override
protected void init() {
try {
LogSummaryAppenderUtils.registerLogSummaryAppender();
super.init();
this.dataSource = platform.getDataSource();
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
configurer.setProperties(parameterService.getAllParameters());
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(springContext);
ctx.addBeanFactoryPostProcessor(configurer);
List<String> extensionLocations = new ArrayList<String>();
extensionLocations.add("classpath:/symmetric-ext-points.xml");
if (registerEngine) {
extensionLocations.add("classpath:/symmetric-jmx.xml");
}
String xml = parameterService.getString(ParameterConstants.EXTENSIONS_XML);
File file = new File(parameterService.getTempDirectory(), "extension.xml");
FileUtils.deleteQuietly(file);
if (isNotBlank(xml)) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
// the "parse" method also validates XML, will throw an exception if misformatted
builder.parse(new InputSource(new StringReader(xml)));
FileUtils.write(file, xml, false);
extensionLocations.add("file:" + file.getAbsolutePath());
} catch (Exception e) {
log.error("Invalid " + ParameterConstants.EXTENSIONS_XML + " parameter.");
}
}
try {
ctx.setConfigLocations(extensionLocations.toArray(new String[extensionLocations.size()]));
ctx.refresh();
this.springContext = ctx;
((ClientExtensionService) this.extensionService).setSpringContext(springContext);
this.extensionService.refresh();
} catch (Exception ex) {
log.error("Failed to initialize the extension points. Please fix the problem and restart the server.", ex);
}
} catch (RuntimeException ex) {
destroy();
throw ex;
}
}
use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project cxf by apache.
the class JsHttpRequestTest method additionalSpringConfiguration.
public void additionalSpringConfiguration(GenericApplicationContext applicationContext) throws Exception {
// bring in some property values from a Properties file
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
Properties properties = new Properties();
properties.setProperty("staticResourceURL", getStaticResourceURL());
cfg.setProperties(properties);
// now actually do the replacement
cfg.postProcessBeanFactory(applicationContext.getBeanFactory());
}
Aggregations