Search in sources :

Example 26 with PropertiesComponent

use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.

the class BaseMinaTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    context.addComponent("properties", new PropertiesComponent("ref:prop"));
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Example 27 with PropertiesComponent

use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.

the class AbstractCamelRunner method setupPropertiesComponent.

public static void setupPropertiesComponent(final CamelContext context, final Map<String, String> props, Logger log) {
    // Set up PropertiesComponent
    PropertiesComponent pc = new PropertiesComponent();
    if (context.getComponentNames().contains("properties")) {
        pc = context.getComponent("properties", PropertiesComponent.class);
    } else {
        context.addComponent("properties", pc);
    }
    // Set property prefix
    if (System.getProperty(PROPERTY_PREFIX) != null) {
        pc.setPropertyPrefix(System.getProperty(PROPERTY_PREFIX) + ".");
    }
    if (props != null) {
        Properties initialProps = new Properties();
        initialProps.putAll(props);
        log.debug(String.format("Added %d initial properties", props.size()));
        pc.setInitialProperties(initialProps);
    }
}
Also used : Properties(java.util.Properties) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Example 28 with PropertiesComponent

use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.

the class GroovyPropertyComponentTest method createRouteBuilder.

protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        public void configure() throws Exception {
            PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
            pc.setLocation("org/apache/camel/builder/script/myproperties.properties");
            from("direct:start").choice().when().groovy("request.headers.get('foo') == context.resolvePropertyPlaceholders('{{foo}}')").to("mock:result").otherwise().to("mock:unmatched");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Example 29 with PropertiesComponent

use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.

the class CamelAutoConfiguration method properties.

@Bean(initMethod = "", destroyMethod = "")
// Camel handles the lifecycle of this bean
PropertiesComponent properties(CamelContext camelContext, PropertiesParser parser) {
    if (camelContext.hasComponent("properties") != null) {
        return camelContext.getComponent("properties", PropertiesComponent.class);
    } else {
        PropertiesComponent pc = new PropertiesComponent();
        pc.setPropertiesParser(parser);
        return pc;
    }
}
Also used : PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 30 with PropertiesComponent

use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.

the class BaseUrlRewriteTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    context.addComponent("properties", new PropertiesComponent("ref:prop"));
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Aggregations

PropertiesComponent (org.apache.camel.component.properties.PropertiesComponent)83 CamelContext (org.apache.camel.CamelContext)35 Properties (java.util.Properties)17 ApplicationScoped (javax.enterprise.context.ApplicationScoped)12 Produces (javax.enterprise.inject.Produces)12 Named (javax.inject.Named)12 RouteBuilder (org.apache.camel.builder.RouteBuilder)11 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)8 PropertiesLocation (org.apache.camel.component.properties.PropertiesLocation)7 SpringCamelContext (org.apache.camel.spring.SpringCamelContext)6 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)5 Test (org.junit.Test)5 HashMap (java.util.HashMap)3 Component (org.apache.camel.Component)3 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 Exchange (org.apache.camel.Exchange)2