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}");
}
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("*********************************************************************************");
}
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;
}
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);
}
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;
}
Aggregations