use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.
the class CamelContextHelper method lookupPropertiesComponent.
/**
* Lookup the {@link org.apache.camel.component.properties.PropertiesComponent} from the {@link org.apache.camel.CamelContext}.
* <p/>
* @param camelContext the camel context
* @param autoCreate whether to automatic create a new default {@link org.apache.camel.component.properties.PropertiesComponent} if no custom component
* has been configured.
* @return the properties component, or <tt>null</tt> if none has been defined, and auto create is <tt>false</tt>.
*/
public static Component lookupPropertiesComponent(CamelContext camelContext, boolean autoCreate) {
// no existing properties component so lookup and add as component if possible
PropertiesComponent answer = (PropertiesComponent) camelContext.hasComponent("properties");
if (answer == null) {
// lookup what is stored under properties, as it may not be the Camel properties component
Object found = camelContext.getRegistry().lookupByName("properties");
if (found != null && found instanceof PropertiesComponent) {
answer = (PropertiesComponent) found;
camelContext.addComponent("properties", answer);
}
}
if (answer == null && autoCreate) {
// create a default properties component to be used as there may be default values we can use
LOG.info("No existing PropertiesComponent has been configured, creating a new default PropertiesComponent with name: properties");
// do not auto create using getComponent as spring auto-wire by constructor causes a side effect
answer = new PropertiesComponent(true);
camelContext.addComponent("properties", answer);
}
return answer;
}
use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.
the class FilerProducerDoneFileNameRouteTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
myProp.put("myDir", "target/done");
PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
pc.setLocation("ref:myProp");
from("direct:start").to("file:{{myDir}}?doneFileName=done-${file:name}").to("mock:result");
}
};
}
use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.
the class ManagedFromRestPlaceholderTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
registry.put("dummy-test", new DummyRestConsumerFactory());
CamelContext answer = new DefaultCamelContext(registry);
PropertiesComponent pc = new PropertiesComponent();
pc.setLocation("classpath:org/apache/camel/management/rest.properties");
answer.addComponent("properties", pc);
return answer;
}
use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.
the class PropertyInjectAnnotationParameterTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext context = super.createCamelContext();
PropertiesComponent pc = new PropertiesComponent();
Properties props = new Properties();
props.put("greeting", "Hello");
props.put("times", "3");
pc.setInitialProperties(props);
context.addComponent("properties", pc);
return context;
}
use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.
the class AdvisedRouteTest method configuration.
@Produces
@ApplicationScoped
@Named("properties")
private static PropertiesComponent configuration() {
Properties properties = new Properties();
properties.put("from", "inbound");
properties.put("to", "direct:outbound");
properties.put("header.message", "n/a");
PropertiesComponent component = new PropertiesComponent();
component.setInitialProperties(properties);
return component;
}
Aggregations