PollEnrich Java DSL should allow to use agg strategy by reference more easily


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fa94ed99
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fa94ed99
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fa94ed99

Branch: refs/heads/master
Commit: fa94ed995c87ffe5aea670a720add31c1a915e14
Parents: 5cd4af7
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Jun 8 14:23:29 2016 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Jun 8 14:28:41 2016 +0200

----------------------------------------------------------------------
 .../apache/camel/model/ProcessorDefinition.java | 60 +++++++++++++++++++-
 1 file changed, 57 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fa94ed99/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java 
b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index c178af5..47b014e 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -3489,11 +3489,34 @@ public abstract class ProcessorDefinition<Type extends 
ProcessorDefinition<Type>
      * 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.
+     * @return the builder
+     * @see org.apache.camel.processor.PollEnricher
+     */
+    @SuppressWarnings("unchecked")
+    public Type pollEnrich(String resourceUri, long timeout, String 
aggregationStrategyRef) {
+        return pollEnrich(resourceUri, timeout, aggregationStrategyRef, false);
+    }
+
+    /**
+     * 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.
+     * @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
      */
@@ -3520,6 +3543,37 @@ public abstract class ProcessorDefinition<Type extends 
ProcessorDefinition<Type>
      * 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(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;
+    }
+
+    /**
+     * 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.
      * @return the builder
@@ -3527,7 +3581,7 @@ public abstract class ProcessorDefinition<Type extends 
ProcessorDefinition<Type>
      */
     @SuppressWarnings("unchecked")
     public Type pollEnrich(String resourceUri, long timeout) {
-        return pollEnrich(resourceUri, timeout, null);
+        return pollEnrich(resourceUri, timeout, (String) null);
     }
 
     /**

Reply via email to