Skip to content

Instantly share code, notes, and snippets.

@iocanel
Created June 16, 2015 15:43
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 iocanel/4d8cb3f91a81fdc16f4d to your computer and use it in GitHub Desktop.
Save iocanel/4d8cb3f91a81fdc16f4d to your computer and use it in GitHub Desktop.
Route builder with cdi and fabric8 annotations
import io.fabric8.annotations.Alias;
import io.fabric8.annotations.ServiceName;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.cdi.ContextName;
import org.apache.camel.model.language.ConstantExpression;
import javax.ejb.Startup;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.sql.DataSource;
@ContextName("myCdiCamelContext")
@Startup
@ApplicationScoped
public class MyRoutes extends RouteBuilder {
@Inject
@ServiceName("mysql-service")
@Alias("customerds")
DataSource dataSource;
@Override
public void configure() throws Exception {
from("jetty:http://0.0.0.0:8080/list/")
.setBody(new ConstantExpression("select * from customers"))
.to("jdbc:customerds");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment