CAMEL-6763: Added configurePollingConsumer method to DefaultEndpont for 
componets to use when configuring the created polling consumer.


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

Branch: refs/heads/master
Commit: 053437df42f5978afd7b348f24396e8f6bcdc1d3
Parents: 1741e0b
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Sep 18 10:04:44 2013 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Sep 18 10:04:44 2013 +0200

----------------------------------------------------------------------
 .../org/apache/camel/impl/DefaultEndpoint.java  |  4 +++
 .../apache/camel/impl/ProcessorEndpoint.java    |  2 +-
 .../camel/impl/ScheduledPollEndpoint.java       | 32 +++++++++++++++++---
 .../camel/component/http/HttpEndpoint.java      |  2 +-
 .../camel/component/http4/HttpEndpoint.java     |  2 +-
 .../apache/camel/component/jms/JmsEndpoint.java |  2 +-
 .../component/jt400/Jt400DataQueueEndpoint.java | 20 +-----------
 7 files changed, 37 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/053437df/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java 
b/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
index 3e8146a..b88d148 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
@@ -370,6 +370,10 @@ public abstract class DefaultEndpoint extends 
ServiceSupport implements Endpoint
         }
     }
 
+    protected void configurePollingConsumer(PollingConsumer consumer) throws 
Exception {
+        configureConsumer(consumer);
+    }
+
     @Override
     protected void doStart() throws Exception {
         // noop

http://git-wip-us.apache.org/repos/asf/camel/blob/053437df/camel-core/src/main/java/org/apache/camel/impl/ProcessorEndpoint.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/impl/ProcessorEndpoint.java 
b/camel-core/src/main/java/org/apache/camel/impl/ProcessorEndpoint.java
index 231ecb6..0d05878 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ProcessorEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ProcessorEndpoint.java
@@ -76,7 +76,7 @@ public class ProcessorEndpoint extends DefaultPollingEndpoint 
{
     @Override
     public PollingConsumer createPollingConsumer() throws Exception {
         PollingConsumer answer = new ProcessorPollingConsumer(this, 
getProcessor());
-        configureConsumer(answer);
+        configurePollingConsumer(answer);
         return answer;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/053437df/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java 
b/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
index cc63ddc..57595b1 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
@@ -21,6 +21,9 @@ import java.util.Map;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Component;
+import org.apache.camel.PollingConsumer;
+import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.util.EndpointHelper;
 import org.apache.camel.util.IntrospectionSupport;
 
 /**
@@ -74,7 +77,7 @@ public abstract class ScheduledPollEndpoint extends 
DefaultEndpoint {
         Object backoffIdleThreshold  = options.remove("backoffIdleThreshold");
         Object backoffErrorThreshold  = 
options.remove("backoffErrorThreshold");
         boolean setConsumerProperties = false;
-        
+
         // the following is split into two if statements to satisfy the 
checkstyle max complexity constraint
         if (initialDelay != null || delay != null || timeUnit != null || 
useFixedDelay != null || pollStrategy != null) {
             setConsumerProperties = true;
@@ -85,9 +88,9 @@ public abstract class ScheduledPollEndpoint extends 
DefaultEndpoint {
         if (scheduler != null || !schedulerProperties.isEmpty() || 
backoffMultiplier != null || backoffIdleThreshold != null || 
backoffErrorThreshold != null) {
             setConsumerProperties = true;
         }
-        
+
         if (setConsumerProperties) {
-        
+
             if (consumerProperties == null) {
                 consumerProperties = new HashMap<String, Object>();
             }
@@ -154,5 +157,26 @@ public abstract class ScheduledPollEndpoint extends 
DefaultEndpoint {
             }
         }
     }
-    
+
+    @Override
+    protected void configurePollingConsumer(PollingConsumer consumer) throws 
Exception {
+        Map<String, Object> copy = new HashMap<String, 
Object>(getConsumerProperties());
+        Map<String, Object> throwaway = new HashMap<String, Object>();
+
+        // filter out unwanted options which is intended for the scheduled 
poll consumer
+        // as these options are not supported on the polling consumer
+        configureScheduledPollConsumerProperties(copy, throwaway);
+
+        // set reference properties first as they use # syntax that fools the 
regular properties setter
+        EndpointHelper.setReferenceProperties(getCamelContext(), consumer, 
copy);
+        EndpointHelper.setProperties(getCamelContext(), consumer, copy);
+
+        if (!isLenientProperties() && copy.size() > 0) {
+            throw new ResolveEndpointFailedException(this.getEndpointUri(), 
"There are " + copy.size()
+                    + " parameters that couldn't be set on the endpoint 
polling consumer."
+                    + " Check the uri if the parameters are spelt correctly 
and that they are properties of the endpoint."
+                    + " Unknown consumer parameters=[" + copy + "]");
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/053437df/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
 
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
index 79d88d9..29cfd17 100644
--- 
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
+++ 
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
@@ -96,7 +96,7 @@ public class HttpEndpoint extends DefaultPollingEndpoint 
implements HeaderFilter
 
     public PollingConsumer createPollingConsumer() throws Exception {
         HttpPollingConsumer answer = new HttpPollingConsumer(this);
-        configureConsumer(answer);
+        configurePollingConsumer(answer);
         return answer;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/053437df/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
 
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
index 20ef282..06bc133 100644
--- 
a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
+++ 
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
@@ -103,7 +103,7 @@ public class HttpEndpoint extends DefaultPollingEndpoint 
implements HeaderFilter
 
     public PollingConsumer createPollingConsumer() throws Exception {
         HttpPollingConsumer answer = new HttpPollingConsumer(this);
-        configureConsumer(answer);
+        configurePollingConsumer(answer);
         return answer;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/053437df/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
index 322ca6b..a8110af 100644
--- 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
+++ 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
@@ -263,7 +263,7 @@ public class JmsEndpoint extends DefaultEndpoint implements 
HeaderFilterStrategy
     public PollingConsumer createPollingConsumer() throws Exception {
         JmsOperations template = createInOnlyTemplate();
         JmsPollingConsumer answer = new JmsPollingConsumer(this, template);
-        configureConsumer(answer);
+        configurePollingConsumer(answer);
         return answer;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/053437df/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueEndpoint.java
 
b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueEndpoint.java
index b9b5797..51b4d89 100644
--- 
a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueEndpoint.java
+++ 
b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueEndpoint.java
@@ -147,25 +147,7 @@ public class Jt400DataQueueEndpoint extends 
DefaultPollingEndpoint {
     @Override
     public PollingConsumer createPollingConsumer() throws Exception {
         Jt400DataQueueConsumer answer = new Jt400DataQueueConsumer(this);
-
-        Map<String, Object> copy = new HashMap<String, 
Object>(getConsumerProperties());
-        Map<String, Object> throwaway = new HashMap<String, Object>();
-
-        // filter out unwanted options which is intended for the scheduled 
poll consumer
-        // as these options are not supported on Jt400DataQueueConsumer
-        configureScheduledPollConsumerProperties(copy, throwaway);
-
-        // set reference properties first as they use # syntax that fools the 
regular properties setter
-        EndpointHelper.setReferenceProperties(getCamelContext(), this, copy);
-        EndpointHelper.setProperties(getCamelContext(), this, copy);
-
-        if (!isLenientProperties() && copy.size() > 0) {
-            throw new ResolveEndpointFailedException(this.getEndpointUri(), 
"There are " + copy.size()
-                    + " parameters that couldn't be set on the endpoint 
consumer."
-                    + " Check the uri if the parameters are spelt correctly 
and that they are properties of the endpoint."
-                    + " Unknown consumer parameters=[" + copy + "]");
-        }
-
+        configurePollingConsumer(answer);
         return answer;
     }
 

Reply via email to