Search in sources :

Example 11 with PropertiesComponent

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

the class DumpModelAsXmlPlaceholdersTest method createCamelContext.

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

Example 12 with PropertiesComponent

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

the class FilerProducerDoneFileNameTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
    pc.setLocation("ref:myProp");
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Example 13 with PropertiesComponent

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

the class SimpleWithPropertiesTest method testProperty.

/**
     * A property from the property component in a expression 
     * is processed when the expression is evaluated with exchange
     * See https://issues.apache.org/jira/browse/CAMEL-4843
     * Now camel doesn't support the properties expression of {{test}}
     */
@Test
public void testProperty() throws Exception {
    System.setProperty("test", "testValue");
    PropertiesComponent pc = new PropertiesComponent();
    CamelContext context = new DefaultCamelContext();
    context.addComponent("properties", pc);
    // try to setup the property
    Exchange exchange = new DefaultExchange(context);
    String result = SimpleBuilder.simple("${properties:test}").evaluate(exchange, String.class);
    Assert.assertEquals("testValue", result);
    System.clearProperty("test");
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 14 with PropertiesComponent

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

the class BaseAhcTest 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 15 with PropertiesComponent

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

the class AMQPConnectionDetails method discoverAMQP.

public static AMQPConnectionDetails discoverAMQP(CamelContext camelContext) {
    try {
        PropertiesComponent propertiesComponent = camelContext.getComponent("properties", PropertiesComponent.class);
        String host = property(propertiesComponent, AMQP_HOST, "localhost");
        int port = Integer.parseInt(property(propertiesComponent, AMQP_PORT, "5672"));
        String username = property(propertiesComponent, AMQP_USERNAME, null);
        String password = property(propertiesComponent, AMQP_PASSWORD, null);
        return new AMQPConnectionDetails("amqp://" + host + ":" + port, username, password);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : 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