@Override protected RouteBuilder[] createRouteBuilders() throws Exception { return new RouteBuilder[] {new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").setHeader("xsd_file", new ConstantExpression("org/apache/camel/component/validator/xsds/person.xsd")) .recipientList(new SimpleExpression("validator:${header.xsd_file}?resourceResolverFactory=#resourceResolverFactory")).to("mock:end"); } }, new RouteBuilder() { @Override public void configure() throws Exception { from("direct:startComponent").setHeader("xsd_file", new ConstantExpression("org/apache/camel/component/validator/xsds/person.xsd")) .recipientList(new SimpleExpression("validator:${header.xsd_file}")).to("mock:end"); } }}; }
@Override protected RouteBuilder[] createRouteBuilders() throws Exception { return new RouteBuilder[] {new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start") // .setHeader("xslt_file", new ConstantExpression("xslt/staff/staff.xsl")) // .recipientList(new SimpleExpression("xslt:${header.xslt_file}?uriResolverFactory=#uriResolverFactory")) // .to("mock:result"); } }, new RouteBuilder() { @Override public void configure() throws Exception { from("direct:startComponent") // .setHeader("xslt_file", new ConstantExpression("xslt/staff/staff.xsl")) // .recipientList(new SimpleExpression("xslt:${header.xslt_file}")) // .to("mock:result"); } }}; }
@Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { Tracer tracer = new Tracer(); getContext().addInterceptStrategy(tracer); from("file:target/split").routeId("foo").noAutoStartup() .split(body().tokenize(comma)) .parallelProcessing() .streaming() .setProperty("split", new SimpleExpression("${property.CamelSplitIndex}")) .split(body().tokenize(LS)) .parallelProcessing() .streaming() .setBody(body().append(":Status=OK").append(LS)) .to("file:target/split/outbox?fileExist=Append&fileName=result${property.split}.txt") .end() .setBody(new SimpleExpression("${property.split} complete")) .to("file:target/split/outbox?fileExist=Append&fileName=result${property.split}.txt") .end().to("mock:result"); } }; }
public DedupeDefinition() { // configure a fictive expression to avoid NPE in // org.apache.camel.model.language.ExpressionDefinition.createExpression() super(new SimpleExpression()); }
/** * An expression of an inbound message body */ public T body() { // reuse simple as this allows the model to represent this as a known JAXB type return expression(new SimpleExpression("body")); }
/** * Returns a simple expression */ public static ValueBuilder simple(String value) { Expression exp = new SimpleExpression(value); return new ValueBuilder(exp); }
/** * Returns a simple expression */ public static ValueBuilder simple(String value, Class<?> resultType) { SimpleExpression exp = new SimpleExpression(value); exp.setResultType(resultType); return new ValueBuilder(exp); }
/** * Returns a predicate and value builder for the inbound body on an exchange */ public static ValueBuilder body() { Expression exp = new SimpleExpression("${body}"); return new ValueBuilder(exp); }
/** * Returns a predicate and value builder for the inbound message body as a * specific type */ public static <T> ValueBuilder bodyAs(Class<T> type) { ObjectHelper.notNull(type, "type"); Expression exp = new SimpleExpression(String.format("${bodyAs(%s)}", type.getCanonicalName())); return new ValueBuilder(exp); }
/** * Returns an expression for the given system property */ public static ValueBuilder systemProperty(final String name) { Expression exp = new SimpleExpression(String.format("${sys.%s}", name)); return new ValueBuilder(exp); }
/** * Returns a predicate and value builder for the exception message on an exchange */ public static ValueBuilder exceptionMessage() { Expression exp = new SimpleExpression("${exception.message}"); return new ValueBuilder(exp); }
/** * Returns a predicate and value builder for the exception stacktrace on an exchange */ public static ValueBuilder exceptionStackTrace() { Expression exp = new SimpleExpression("${exception.stacktrace}"); return new ValueBuilder(exp); }
/** * The <a href="http://camel.apache.org/content-enricher.html">Content Enricher EIP</a> * enriches an exchange with additional data obtained from a <code>resourceUri</code>. * <p/> * The difference between this and {@link #pollEnrich(String)} is that this uses a producer * to obtain the additional data, where as pollEnrich uses a polling consumer. * * @param resourceRef Reference of resource endpoint for obtaining additional data. * @param aggregationStrategyRef Reference of aggregation strategy to aggregate input data and additional data. * @param aggregateOnException whether to call {@link org.apache.camel.processor.aggregate.AggregationStrategy#aggregate(org.apache.camel.Exchange, org.apache.camel.Exchange)} if * an exception was thrown. * @param shareUnitOfWork whether to share unit of work * @return the builder * @see org.apache.camel.processor.Enricher * @deprecated use enrich with a <tt>ref:id</tt> as the resourceUri parameter. */ @Deprecated @SuppressWarnings("unchecked") public Type enrichRef(String resourceRef, String aggregationStrategyRef, boolean aggregateOnException, boolean shareUnitOfWork) { EnrichDefinition answer = new EnrichDefinition(); answer.setExpression(new SimpleExpression("ref:" + resourceRef)); answer.setAggregationStrategyRef(aggregationStrategyRef); answer.setAggregateOnException(aggregateOnException); answer.setShareUnitOfWork(shareUnitOfWork); addOutput(answer); return (Type) this; }
/** * The <a href="http://camel.apache.org/content-enricher.html">Content Enricher EIP</a> * enriches an exchange with additional data obtained from a <code>resourceUri</code> * using a {@link org.apache.camel.PollingConsumer} to poll the endpoint. * <p/> * The difference between this and {@link #enrich(String)} is that this uses a consumer * to obtain the additional data, where as enrich uses a producer. * <p/> * The timeout controls which operation to use on {@link org.apache.camel.PollingConsumer}. * If timeout is negative, we use <tt>receive</tt>. If timeout is 0 then we use <tt>receiveNoWait</tt> * otherwise we use <tt>receive(timeout)</tt>. * * @param resourceRef Reference of resource endpoint for obtaining additional data. * @param timeout timeout in millis to wait at most for data to be available. * @param aggregationStrategyRef Reference of aggregation strategy to aggregate input data and additional data. * @return the builder * @see org.apache.camel.processor.PollEnricher * @deprecated use pollEnrich with a <tt>ref:id</tt> as the resourceUri parameter. */ @Deprecated @SuppressWarnings("unchecked") public Type pollEnrichRef(String resourceRef, long timeout, String aggregationStrategyRef) { PollEnrichDefinition pollEnrich = new PollEnrichDefinition(); pollEnrich.setExpression(new SimpleExpression("ref:" + resourceRef)); pollEnrich.setTimeout(timeout); pollEnrich.setAggregationStrategyRef(aggregationStrategyRef); addOutput(pollEnrich); return (Type) this; }
/** * The <a href="http://camel.apache.org/content-enricher.html">Content Enricher EIP</a> * enriches an exchange with additional data obtained from a <code>resourceUri</code> * using a {@link org.apache.camel.PollingConsumer} to poll the endpoint. * <p/> * The difference between this and {@link #enrich(String)} is that this uses a consumer * to obtain the additional data, where as enrich uses a producer. * <p/> * The timeout controls which operation to use on {@link org.apache.camel.PollingConsumer}. * If timeout is negative, we use <tt>receive</tt>. If timeout is 0 then we use <tt>receiveNoWait</tt> * otherwise we use <tt>receive(timeout)</tt>. * * @param resourceRef Reference of resource endpoint for obtaining additional data. * @param timeout timeout in millis to wait at most for data to be available. * @param aggregationStrategyRef Reference of aggregation strategy to aggregate input data and additional data. * @param aggregateOnException whether to call {@link org.apache.camel.processor.aggregate.AggregationStrategy#aggregate(org.apache.camel.Exchange, org.apache.camel.Exchange)} if * an exception was thrown. * @return the builder * @see org.apache.camel.processor.PollEnricher * @deprecated use pollEnrich with a <tt>ref:id</tt> as the resourceUri parameter. */ @Deprecated @SuppressWarnings("unchecked") public Type pollEnrichRef(String resourceRef, long timeout, String aggregationStrategyRef, boolean aggregateOnException) { PollEnrichDefinition pollEnrich = new PollEnrichDefinition(); pollEnrich.setExpression(new SimpleExpression("ref:" + resourceRef)); pollEnrich.setTimeout(timeout); pollEnrich.setAggregationStrategyRef(aggregationStrategyRef); pollEnrich.setAggregateOnException(aggregateOnException); addOutput(pollEnrich); return (Type) this; }
/** * Evaluates a <a href="http://camel.apache.org/simple.html">Simple * expression</a> * * @param text the expression to be evaluated * @param resultType the result type * @return the builder to continue processing the DSL */ public T simple(String text, Class<?> resultType) { SimpleExpression expression = new SimpleExpression(text); expression.setResultType(resultType); setExpressionType(expression); return result; }
/** * Evaluates a <a href="http://camel.apache.org/simple.html">Simple * expression</a> * * @param text the expression to be evaluated * @return the builder to continue processing the DSL */ public T simple(String text) { return expression(new SimpleExpression(text)); }
/** * Returns a predicate and value builder for the outbound body on an * exchange * * @deprecated use {@link #body()} */ @Deprecated public static ValueBuilder outBody() { Expression exp = new SimpleExpression("${out.body}"); return new ValueBuilder(exp); }