@ApplicationScoped @ContextName("simple") public class SimpleCamelContext extends CdiCamelContext { @PostConstruct void postConstruct() { // Enable Tracing super.setTracing(false); // Define PropertyPlaceHolder getComponent("properties", PropertiesComponent.class).setLocation("classpath:placeholder.properties"); try { super.start(); } catch (Exception cause) { throw ObjectHelper.wrapRuntimeCamelException(cause); } } @PreDestroy void preDestroy() { try { super.stop(); } catch (Exception cause) { throw ObjectHelper.wrapRuntimeCamelException(cause); } } }
private static CamelContextNameStrategy nameStrategy(Annotated annotated) { if (annotated.isAnnotationPresent(ContextName.class)) { return new ExplicitCamelContextNameStrategy(annotated.getAnnotation(ContextName.class).value()); } else if (annotated.isAnnotationPresent(Named.class)) { // TODO: support stereotype with empty @Named annotation String name = annotated.getAnnotation(Named.class).value(); if (name.isEmpty()) { if (annotated instanceof AnnotatedField) { name = ((AnnotatedField) annotated).getJavaMember().getName(); } else if (annotated instanceof AnnotatedMethod) { name = ((AnnotatedMethod) annotated).getJavaMember().getName(); if (name.startsWith("get")) { name = decapitalize(name.substring(3)); } } else { name = decapitalize(getRawType(annotated.getBaseType()).getSimpleName()); } } return new ExplicitCamelContextNameStrategy(name); } else { // Use a specific naming strategy for Camel CDI as the default one increments the suffix for each CDI proxy created return new CdiCamelContextNameStrategy(); } } }
@ContextName("simple") public class SimpleCamelRoute extends RouteBuilder { @ContextName("simple") private Endpoint directEP;
/** * Configures all our Camel routes, components, endpoints and beans */ @ContextName("myCdiRestCamelContext") public class MyRoutes extends RouteBuilder { @Inject @Uri("timer:foo?period=5000") private Endpoint inputEndpoint; @Inject @Uri("http:{{service:QUICKSTART_REST:localhost:8080}}/cxf/customerservice/customers/123") private Endpoint restEndpoint; @Inject @Uri("log:output?showExchangePattern=false&showBodyType=false&showStreams=true") private Endpoint resultEndpoint; @Override public void configure() throws Exception { // you can configure the route rule with Java DSL here from(inputEndpoint) .to(restEndpoint) .to(resultEndpoint); } }
@ContextName(value="camelctx") public class HelloServiceJMS extends RouteBuilder implements HelloService { private final DataFormat helloObjectJSonFormat = new JacksonDataFormat(HelloEntity.class, Hellos.class);