Skip to content

Instantly share code, notes, and snippets.

@gautric
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gautric/7b03d5b352d29ee71dbb to your computer and use it in GitHub Desktop.
Save gautric/7b03d5b352d29ee71dbb to your computer and use it in GitHub Desktop.
CamelMain
package com.github.camellabs.component.pi4j;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.model.RouteDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A simple application to run RaspberryPi Camel
*/
public final class CamelMain {
private static final Logger LOG = LoggerFactory.getLogger(CamelMain.class);
private CamelMain() {
}
public static class CommandLineRouteBuilder extends RouteBuilder {
String[] args;
CommandLineRouteBuilder(String[] args) {
this.args = args;
}
@Override
public void configure() throws Exception {
RouteDefinition rd = from(args[0]).id("raspberrypi-route");
rd = rd.to(Pi4jConstants.LOG_COMPONENT);
for (int i = 1; i < args.length; i++) {
rd = rd.to(args[i]);
}
}
}
public static void main(String[] args) throws Exception {
LOG.info("main");
for (int i = 0; i < args.length; i++) {
LOG.info("args[" + i + "] = " + args[i]);
}
CamelContext context = new DefaultCamelContext();
context.addRoutes(new CommandLineRouteBuilder(args));
context.start();
Thread.sleep(60000);
context.stop();
System.exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment