You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/09/16 12:42:41 UTC

[1/5] git commit: CAMEL-6729: camel-jt400 filter unsupported scheduled poll consumer options when creating a PollingConsumer as it does not support these options, due special in jt400 component.

Updated Branches:
  refs/heads/camel-2.11.x aebe52774 -> 0acff1b0a
  refs/heads/camel-2.12.x 4db3d9e12 -> a971b79da
  refs/heads/master 89c61cacc -> 302133ed3


CAMEL-6729: camel-jt400 filter unsupported scheduled poll consumer options when creating a PollingConsumer as it does not support these options, due special in jt400 component.


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

Branch: refs/heads/master
Commit: 0dbb9ea266f640c3859703f90fe5b5b98e27e579
Parents: 89c61ca
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Sep 16 12:40:53 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 16 12:40:53 2013 +0200

----------------------------------------------------------------------
 .../camel/impl/ScheduledPollEndpoint.java       |  2 +-
 .../component/jt400/Jt400DataQueueEndpoint.java | 24 ++++++-
 .../jt400/Jt400CustomPollStrategyTest.java      | 71 ++++++++++++++++++++
 3 files changed, 95 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0dbb9ea2/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 9106ef3..cc63ddc 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
@@ -55,7 +55,7 @@ public abstract class ScheduledPollEndpoint extends DefaultEndpoint {
         configureScheduledPollConsumerProperties(options, getConsumerProperties());
     }
 
-    private void configureScheduledPollConsumerProperties(Map<String, Object> options, Map<String, Object> consumerProperties) {
+    protected void configureScheduledPollConsumerProperties(Map<String, Object> options, Map<String, Object> consumerProperties) {
         // special for scheduled poll consumers as we want to allow end users to configure its options
         // from the URI parameters without the consumer. prefix
         Map<String, Object> schedulerProperties = IntrospectionSupport.extractProperties(options, "scheduler.");

http://git-wip-us.apache.org/repos/asf/camel/blob/0dbb9ea2/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 3692864..b9b5797 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
@@ -18,6 +18,8 @@ package org.apache.camel.component.jt400;
 
 import java.beans.PropertyVetoException;
 import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
 
 import com.ibm.as400.access.AS400;
 import com.ibm.as400.access.AS400ConnectionPool;
@@ -27,7 +29,9 @@ import com.ibm.as400.access.KeyedDataQueue;
 import org.apache.camel.CamelException;
 import org.apache.camel.PollingConsumer;
 import org.apache.camel.Producer;
+import org.apache.camel.ResolveEndpointFailedException;
 import org.apache.camel.impl.DefaultPollingEndpoint;
+import org.apache.camel.util.EndpointHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
 
@@ -143,7 +147,25 @@ public class Jt400DataQueueEndpoint extends DefaultPollingEndpoint {
     @Override
     public PollingConsumer createPollingConsumer() throws Exception {
         Jt400DataQueueConsumer answer = new Jt400DataQueueConsumer(this);
-        configureConsumer(answer);
+
+        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 + "]");
+        }
+
         return answer;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/0dbb9ea2/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400CustomPollStrategyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400CustomPollStrategyTest.java b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400CustomPollStrategyTest.java
new file mode 100644
index 0000000..de1ff19
--- /dev/null
+++ b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400CustomPollStrategyTest.java
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jt400;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.PollingConsumer;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.spi.PollingConsumerPollStrategy;
+import org.junit.Test;
+
+public class Jt400CustomPollStrategyTest extends Jt400TestSupport {
+
+    private static final String PASSWORD = "p4ssw0rd";
+    private PollingConsumerPollStrategy poll = new MyPollStrategy();
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("jt400PollStrategy", poll);
+        return jndi;
+    }
+
+    @Test
+    public void testCustomPollStrategy() throws Exception {
+        Jt400DataQueueEndpoint endpoint = resolveMandatoryEndpoint(
+                "jt400://user:" + PASSWORD + "@host/qsys.lib/library.lib/queue.dtaq?connectionPool=#mockPool&pollStrategy=#jt400PollStrategy",
+                Jt400DataQueueEndpoint.class);
+        assertNotNull(endpoint);
+
+        PollingConsumer consumer = endpoint.createPollingConsumer();
+        assertNotNull(consumer);
+    }
+
+    private static final class MyPollStrategy implements PollingConsumerPollStrategy {
+
+        @Override
+        public boolean begin(Consumer consumer, Endpoint endpoint) {
+            return true;
+        }
+
+        @Override
+        public void commit(Consumer consumer, Endpoint endpoint, int i) {
+            // noop
+        }
+
+        @Override
+        public boolean rollback(Consumer consumer, Endpoint endpoint, int i, Exception e) throws Exception {
+            return false;
+        }
+    }
+}


[5/5] git commit: Fixed CS

Posted by da...@apache.org.
Fixed CS


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

Branch: refs/heads/camel-2.11.x
Commit: 0acff1b0a2ab0ed2bad66b1e13c58885e8252b14
Parents: aebe527
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Sep 16 12:41:44 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 16 12:42:21 2013 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/component/bean/BeanInfo.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0acff1b0/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index f288ace..583d6ad 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -613,7 +613,7 @@ public class BeanInfo {
     private MethodInfo getSingleCovariantMethod(Collection<MethodInfo> candidates) {
         // if all the candidates are actually covariant, it doesn't matter which one we call
         MethodInfo firstCandidate = candidates.iterator().next();
-        for (MethodInfo candidate: candidates) {
+        for (MethodInfo candidate : candidates) {
             if (!firstCandidate.isCovariantWith(candidate)) {
                 return null;
             }


[3/5] git commit: CAMEL-6729: camel-jt400 filter unsupported scheduled poll consumer options when creating a PollingConsumer as it does not support these options, due special in jt400 component.

Posted by da...@apache.org.
CAMEL-6729: camel-jt400 filter unsupported scheduled poll consumer options when creating a PollingConsumer as it does not support these options, due special in jt400 component.


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

Branch: refs/heads/camel-2.12.x
Commit: 8ad3d365652597deefd50cf7e5862de40aa0ecbc
Parents: 4db3d9e
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Sep 16 12:40:53 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 16 12:42:00 2013 +0200

----------------------------------------------------------------------
 .../camel/impl/ScheduledPollEndpoint.java       |  2 +-
 .../component/jt400/Jt400DataQueueEndpoint.java | 24 ++++++-
 .../jt400/Jt400CustomPollStrategyTest.java      | 71 ++++++++++++++++++++
 3 files changed, 95 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8ad3d365/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 9106ef3..cc63ddc 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
@@ -55,7 +55,7 @@ public abstract class ScheduledPollEndpoint extends DefaultEndpoint {
         configureScheduledPollConsumerProperties(options, getConsumerProperties());
     }
 
-    private void configureScheduledPollConsumerProperties(Map<String, Object> options, Map<String, Object> consumerProperties) {
+    protected void configureScheduledPollConsumerProperties(Map<String, Object> options, Map<String, Object> consumerProperties) {
         // special for scheduled poll consumers as we want to allow end users to configure its options
         // from the URI parameters without the consumer. prefix
         Map<String, Object> schedulerProperties = IntrospectionSupport.extractProperties(options, "scheduler.");

http://git-wip-us.apache.org/repos/asf/camel/blob/8ad3d365/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 3692864..b9b5797 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
@@ -18,6 +18,8 @@ package org.apache.camel.component.jt400;
 
 import java.beans.PropertyVetoException;
 import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
 
 import com.ibm.as400.access.AS400;
 import com.ibm.as400.access.AS400ConnectionPool;
@@ -27,7 +29,9 @@ import com.ibm.as400.access.KeyedDataQueue;
 import org.apache.camel.CamelException;
 import org.apache.camel.PollingConsumer;
 import org.apache.camel.Producer;
+import org.apache.camel.ResolveEndpointFailedException;
 import org.apache.camel.impl.DefaultPollingEndpoint;
+import org.apache.camel.util.EndpointHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
 
@@ -143,7 +147,25 @@ public class Jt400DataQueueEndpoint extends DefaultPollingEndpoint {
     @Override
     public PollingConsumer createPollingConsumer() throws Exception {
         Jt400DataQueueConsumer answer = new Jt400DataQueueConsumer(this);
-        configureConsumer(answer);
+
+        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 + "]");
+        }
+
         return answer;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/8ad3d365/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400CustomPollStrategyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400CustomPollStrategyTest.java b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400CustomPollStrategyTest.java
new file mode 100644
index 0000000..de1ff19
--- /dev/null
+++ b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400CustomPollStrategyTest.java
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jt400;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.PollingConsumer;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.spi.PollingConsumerPollStrategy;
+import org.junit.Test;
+
+public class Jt400CustomPollStrategyTest extends Jt400TestSupport {
+
+    private static final String PASSWORD = "p4ssw0rd";
+    private PollingConsumerPollStrategy poll = new MyPollStrategy();
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("jt400PollStrategy", poll);
+        return jndi;
+    }
+
+    @Test
+    public void testCustomPollStrategy() throws Exception {
+        Jt400DataQueueEndpoint endpoint = resolveMandatoryEndpoint(
+                "jt400://user:" + PASSWORD + "@host/qsys.lib/library.lib/queue.dtaq?connectionPool=#mockPool&pollStrategy=#jt400PollStrategy",
+                Jt400DataQueueEndpoint.class);
+        assertNotNull(endpoint);
+
+        PollingConsumer consumer = endpoint.createPollingConsumer();
+        assertNotNull(consumer);
+    }
+
+    private static final class MyPollStrategy implements PollingConsumerPollStrategy {
+
+        @Override
+        public boolean begin(Consumer consumer, Endpoint endpoint) {
+            return true;
+        }
+
+        @Override
+        public void commit(Consumer consumer, Endpoint endpoint, int i) {
+            // noop
+        }
+
+        @Override
+        public boolean rollback(Consumer consumer, Endpoint endpoint, int i, Exception e) throws Exception {
+            return false;
+        }
+    }
+}


[4/5] git commit: Fixed CS

Posted by da...@apache.org.
Fixed CS


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

Branch: refs/heads/camel-2.12.x
Commit: a971b79dac4f0f0e9d091d6dc8758c4eb784a884
Parents: 8ad3d36
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Sep 16 12:41:44 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 16 12:42:06 2013 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/component/bean/BeanInfo.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a971b79d/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index 98d0c8b..19d7ad3 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -627,7 +627,7 @@ public class BeanInfo {
     private MethodInfo getSingleCovariantMethod(Collection<MethodInfo> candidates) {
         // if all the candidates are actually covariant, it doesn't matter which one we call
         MethodInfo firstCandidate = candidates.iterator().next();
-        for (MethodInfo candidate: candidates) {
+        for (MethodInfo candidate : candidates) {
             if (!firstCandidate.isCovariantWith(candidate)) {
                 return null;
             }


[2/5] git commit: Fixed CS

Posted by da...@apache.org.
Fixed CS


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

Branch: refs/heads/master
Commit: 302133ed3b488ff07b03644d1c010032581d75f3
Parents: 0dbb9ea
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Sep 16 12:41:44 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 16 12:41:44 2013 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/component/bean/BeanInfo.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/302133ed/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index 98d0c8b..19d7ad3 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -627,7 +627,7 @@ public class BeanInfo {
     private MethodInfo getSingleCovariantMethod(Collection<MethodInfo> candidates) {
         // if all the candidates are actually covariant, it doesn't matter which one we call
         MethodInfo firstCandidate = candidates.iterator().next();
-        for (MethodInfo candidate: candidates) {
+        for (MethodInfo candidate : candidates) {
             if (!firstCandidate.isCovariantWith(candidate)) {
                 return null;
             }