Search in sources :

Example 1 with ConstantExpression

use of org.apache.camel.model.language.ConstantExpression in project camel by apache.

the class ProcessorDefinition method loop.

/**
     * <a href="http://camel.apache.org/loop.html">Loop EIP:</a>
     * Creates a loop allowing to process the a message a number of times and possibly process them
     * in a different way.
     *
     * @param count  the number of times
     * @return the builder
     */
public LoopDefinition loop(int count) {
    LoopDefinition loop = new LoopDefinition(new ConstantExpression(Integer.toString(count)));
    addOutput(loop);
    return loop;
}
Also used : ConstantExpression(org.apache.camel.model.language.ConstantExpression)

Example 2 with ConstantExpression

use of org.apache.camel.model.language.ConstantExpression in project camel by apache.

the class ProcessorDefinition method pollEnrich.

/**
     * 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 resourceUri            URI 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
     */
@SuppressWarnings("unchecked")
public Type pollEnrich(@AsEndpointUri String resourceUri, long timeout, String aggregationStrategyRef, boolean aggregateOnException) {
    PollEnrichDefinition pollEnrich = new PollEnrichDefinition();
    pollEnrich.setExpression(new ConstantExpression(resourceUri));
    pollEnrich.setTimeout(timeout);
    pollEnrich.setAggregationStrategyRef(aggregationStrategyRef);
    pollEnrich.setAggregateOnException(aggregateOnException);
    addOutput(pollEnrich);
    return (Type) this;
}
Also used : XmlAccessorType(javax.xml.bind.annotation.XmlAccessorType) XmlAccessType(javax.xml.bind.annotation.XmlAccessType) ConstantExpression(org.apache.camel.model.language.ConstantExpression)

Example 3 with ConstantExpression

use of org.apache.camel.model.language.ConstantExpression in project camel by apache.

the class ProcessorDefinition method pollEnrich.

/**
     * 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 resourceUri           URI of resource endpoint for obtaining additional data.
     * @param timeout               timeout in millis to wait at most for data to be available.
     * @param aggregationStrategy   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
     */
@SuppressWarnings("unchecked")
public Type pollEnrich(@AsEndpointUri String resourceUri, long timeout, AggregationStrategy aggregationStrategy, boolean aggregateOnException) {
    PollEnrichDefinition pollEnrich = new PollEnrichDefinition();
    pollEnrich.setExpression(new ConstantExpression(resourceUri));
    pollEnrich.setTimeout(timeout);
    pollEnrich.setAggregationStrategy(aggregationStrategy);
    pollEnrich.setAggregateOnException(aggregateOnException);
    addOutput(pollEnrich);
    return (Type) this;
}
Also used : XmlAccessorType(javax.xml.bind.annotation.XmlAccessorType) XmlAccessType(javax.xml.bind.annotation.XmlAccessType) ConstantExpression(org.apache.camel.model.language.ConstantExpression)

Example 4 with ConstantExpression

use of org.apache.camel.model.language.ConstantExpression in project camel by apache.

the class ProcessorDefinition method enrich.

/**
     * 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>.
     *
     * @param resourceUri           URI of resource endpoint for obtaining additional data.
     * @param aggregationStrategy   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
     */
@SuppressWarnings("unchecked")
public Type enrich(@AsEndpointUri String resourceUri, AggregationStrategy aggregationStrategy, boolean aggregateOnException, boolean shareUnitOfWork) {
    EnrichDefinition answer = new EnrichDefinition();
    answer.setExpression(new ConstantExpression(resourceUri));
    answer.setAggregationStrategy(aggregationStrategy);
    answer.setAggregateOnException(aggregateOnException);
    answer.setShareUnitOfWork(shareUnitOfWork);
    addOutput(answer);
    return (Type) this;
}
Also used : XmlAccessorType(javax.xml.bind.annotation.XmlAccessorType) XmlAccessType(javax.xml.bind.annotation.XmlAccessType) ConstantExpression(org.apache.camel.model.language.ConstantExpression)

Aggregations

ConstantExpression (org.apache.camel.model.language.ConstantExpression)4 XmlAccessType (javax.xml.bind.annotation.XmlAccessType)3 XmlAccessorType (javax.xml.bind.annotation.XmlAccessorType)3