Search in sources :

Example 56 with PropertiesComponent

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

the class SplunkSearchRouteBuilder method configure.

@Override
public void configure() throws Exception {
    log.info("About to setup Splunk search route: Splunk Server --> log{results}");
    // configure properties component
    PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class);
    pc.setLocation("classpath:application.properties");
    from("splunk://normal?host={{splunk.host}}&port={{splunk.port}}&delay=10s" + "&username={{splunk.username}}&password={{splunk.password}}&initEarliestTime=08/17/13 08:35:46:456" + "&sourceType=access_combined_wcookie&search=search Code=D | head 5").log("${body}");
}
Also used : PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Example 57 with PropertiesComponent

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

the class MyFtpServerRouteBuilder method configure.

@Override
public void configure() throws Exception {
    // configure properties component
    PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class);
    pc.setLocation("classpath:ftp.properties");
    // lets shutdown faster in case of in-flight messages stack up
    getContext().getShutdownStrategy().setTimeout(10);
    from("{{ftp.server}}").to("file:target/download").log("Downloaded file ${file:name} complete.");
    // use system out so it stand out
    System.out.println("*********************************************************************************");
    System.out.println("Camel will route files from the FTP server: " + getContext().resolvePropertyPlaceholders("{{ftp.server}}") + " to the target/download directory.");
    System.out.println("You can configure the location of the ftp server in the src/main/resources/ftp.properties file.");
    System.out.println("Use ctrl + c to stop this application.");
    System.out.println("*********************************************************************************");
}
Also used : PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Example 58 with PropertiesComponent

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

the class PropertiesConfigurationTest method propertiesComponent.

@Produces
@ApplicationScoped
@Named("properties")
private static PropertiesComponent propertiesComponent() {
    Properties configuration = new Properties();
    configuration.put("property", "value");
    PropertiesComponent component = new PropertiesComponent();
    component.setInitialProperties(configuration);
    component.setLocation("classpath:camel1.properties,classpath:camel2.properties");
    return component;
}
Also used : Properties(java.util.Properties) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 59 with PropertiesComponent

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

the class CamelTestSupport method doSetUp.

private void doSetUp() throws Exception {
    log.debug("setUp test");
    // jmx is enabled if we have configured to use it, or if dump route coverage is enabled (it requires JMX)
    boolean jmx = useJmx() || isDumpRouteCoverage();
    if (jmx) {
        enableJMX();
    } else {
        disableJMX();
    }
    context = (ModelCamelContext) createCamelContext();
    threadCamelContext.set(context);
    assertNotNull("No context found!", context);
    // reduce default shutdown timeout to avoid waiting for 300 seconds
    context.getShutdownStrategy().setTimeout(getShutdownTimeout());
    // set debugger if enabled
    if (isUseDebugger()) {
        if (context.getStatus().equals(ServiceStatus.Started)) {
            log.info("Cannot setting the Debugger to the starting CamelContext, stop the CamelContext now.");
            // we need to stop the context first to setup the debugger
            context.stop();
        }
        context.setDebugger(new DefaultDebugger());
        context.getDebugger().addBreakpoint(breakpoint);
    // note: when stopping CamelContext it will automatic remove the breakpoint
    }
    template = context.createProducerTemplate();
    template.start();
    fluentTemplate = context.createFluentProducerTemplate();
    fluentTemplate.start();
    consumer = context.createConsumerTemplate();
    consumer.start();
    threadTemplate.set(template);
    threadFluentTemplate.set(fluentTemplate);
    threadConsumer.set(consumer);
    // enable auto mocking if enabled
    String pattern = isMockEndpoints();
    if (pattern != null) {
        context.addRegisterEndpointCallback(new InterceptSendToMockEndpointStrategy(pattern));
    }
    pattern = isMockEndpointsAndSkip();
    if (pattern != null) {
        context.addRegisterEndpointCallback(new InterceptSendToMockEndpointStrategy(pattern, true));
    }
    // configure properties component (mandatory for testing)
    PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
    Properties extra = useOverridePropertiesWithPropertiesComponent();
    if (extra != null && !extra.isEmpty()) {
        pc.setOverrideProperties(extra);
    }
    Boolean ignore = ignoreMissingLocationWithPropertiesComponent();
    if (ignore != null) {
        pc.setIgnoreMissingLocation(ignore);
    }
    postProcessTest();
    if (isUseRouteBuilder()) {
        RoutesBuilder[] builders = createRouteBuilders();
        for (RoutesBuilder builder : builders) {
            log.debug("Using created route builder: " + builder);
            context.addRoutes(builder);
        }
        replaceFromEndpoints();
        boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
        if (skip) {
            log.info("Skipping starting CamelContext as system property skipStartingCamelContext is set to be true.");
        } else if (isUseAdviceWith()) {
            log.info("Skipping starting CamelContext as isUseAdviceWith is set to true.");
        } else {
            startCamelContext();
        }
    } else {
        replaceFromEndpoints();
        log.debug("Using route builder from the created context: " + context);
    }
    log.debug("Routing Rules are: " + context.getRoutes());
    assertValidContext(context);
    INIT.set(true);
}
Also used : DefaultDebugger(org.apache.camel.impl.DefaultDebugger) InterceptSendToMockEndpointStrategy(org.apache.camel.impl.InterceptSendToMockEndpointStrategy) Properties(java.util.Properties) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent) RoutesBuilder(org.apache.camel.RoutesBuilder)

Example 60 with PropertiesComponent

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

the class BaseNettyTest 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