use of org.apache.camel.model.language.SimpleExpression in project camel by apache.
the class FileSplitInSplitTest method createRouteBuilder.
@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");
}
};
}
use of org.apache.camel.model.language.SimpleExpression in project camel by apache.
the class ExpressionNodeHelper method toExpressionDefinition.
/**
* Determines which {@link ExpressionDefinition} describes the given predicate best possible.
* <p/>
* This implementation will use types such as {@link SimpleExpression}, {@link XPathExpression} etc.
* if the given predicate is detect as such a type.
*
* @param predicate the predicate
* @return a definition which describes the predicate
*/
public static ExpressionDefinition toExpressionDefinition(Predicate predicate) {
if (predicate instanceof SimpleBuilder) {
SimpleBuilder builder = (SimpleBuilder) predicate;
// we keep the original expression by using the constructor that accepts an expression
SimpleExpression answer = new SimpleExpression(builder);
answer.setExpression(builder.getText());
return answer;
} else if (predicate instanceof XPathBuilder) {
XPathBuilder builder = (XPathBuilder) predicate;
// we keep the original expression by using the constructor that accepts an expression
XPathExpression answer = new XPathExpression(builder);
answer.setExpression(builder.getText());
return answer;
} else if (predicate instanceof ValueBuilder) {
// ValueBuilder wraps the actual predicate so unwrap
ValueBuilder builder = (ValueBuilder) predicate;
Expression expression = builder.getExpression();
if (expression instanceof Predicate) {
predicate = (Predicate) expression;
}
}
if (predicate instanceof ExpressionDefinition) {
return (ExpressionDefinition) predicate;
}
return new ExpressionDefinition(predicate);
}
use of org.apache.camel.model.language.SimpleExpression in project camel by apache.
the class ProcessorDefinition method pollEnrichRef.
/**
* 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;
}
use of org.apache.camel.model.language.SimpleExpression in project camel by apache.
the class ExpressionClauseSupport method simple.
/**
* 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;
}
Aggregations