use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.
the class AbstractMongoDbTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
applicationContext = new AnnotationConfigApplicationContext(EmbedMongoConfiguration.class);
CamelContext ctx = new SpringCamelContext(applicationContext);
PropertiesComponent pc = new PropertiesComponent("classpath:mongodb.test.properties");
ctx.addComponent("properties", pc);
return ctx;
}
use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.
the class AbstractMongoDbTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
applicationContext = new AnnotationConfigApplicationContext(EmbedMongoConfiguration.class);
CamelContext ctx = SpringCamelContext.springCamelContext(applicationContext);
PropertiesComponent pc = new PropertiesComponent("classpath:mongodb.test.properties");
ctx.addComponent("properties", pc);
return ctx;
}
use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.
the class AbstractMongoDbTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
applicationContext = new AnnotationConfigApplicationContext(EmbedMongoConfiguration.class);
@SuppressWarnings("deprecation") CamelContext ctx = SpringCamelContext.springCamelContext(applicationContext);
PropertiesComponent pc = new PropertiesComponent("classpath:mongodb.test.properties");
ctx.addComponent("properties", pc);
return ctx;
}
use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.
the class CamelContextFactoryBean method initPropertyPlaceholder.
@Override
protected void initPropertyPlaceholder() throws Exception {
super.initPropertyPlaceholder();
Map<String, BridgePropertyPlaceholderConfigurer> beans = applicationContext.getBeansOfType(BridgePropertyPlaceholderConfigurer.class);
if (beans.size() == 1) {
// setup properties component that uses this beans
BridgePropertyPlaceholderConfigurer configurer = beans.values().iterator().next();
String id = beans.keySet().iterator().next();
LOG.info("Bridging Camel and Spring property placeholder configurer with id: " + id);
// get properties component
PropertiesComponent pc = (PropertiesComponent) getContext().getComponent("properties", false);
if (pc == null) {
// do not auto create the component as spring autowrire by constructor causes a side effect when using bridge
pc = new PropertiesComponent();
getContext().addComponent("properties", pc);
}
// use the spring system properties mode which has a different value than Camel may have
pc.setSystemPropertiesMode(configurer.getSystemPropertiesMode());
// replace existing resolver with us
configurer.setResolver(pc.getPropertiesResolver());
configurer.setParser(pc.getPropertiesParser());
// use the bridge to handle the resolve and parsing
pc.setPropertiesResolver(configurer);
pc.setPropertiesParser(configurer);
// and update locations to have our as ref first
List<PropertiesLocation> locations = new ArrayList<>(pc.getLocations());
locations.add(0, new PropertiesLocation("ref", id));
pc.setLocations(locations);
} else if (beans.size() > 1) {
LOG.warn("Cannot bridge Camel and Spring property placeholders, as exact only 1 bean of type BridgePropertyPlaceholderConfigurer" + " must be defined, was {} beans defined.", beans.size());
}
}
use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.
the class Main method setPropertyPlaceholderLocations.
/**
* A list of locations to load properties. You can use comma to separate multiple locations.
* This option will override any default locations and only use the locations from this option.
*/
protected void setPropertyPlaceholderLocations(String location) {
PropertiesComponent pc = new PropertiesComponent();
pc.setLocation(location);
bind("properties", pc);
}
Aggregations