You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/08/12 10:01:52 UTC
[1/3] git commit: CAMEL-7679 Fixed the Second argument is null issue
of camel-cxfrs
Repository: camel
Updated Branches:
refs/heads/master fe35d1be5 -> 759a4d62b
CAMEL-7679 Fixed the Second argument is null issue of camel-cxfrs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ab8d8102
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ab8d8102
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ab8d8102
Branch: refs/heads/master
Commit: ab8d8102341819c740c6a95883d21d48e0381617
Parents: e9a20c1
Author: Willem Jiang <wi...@gmail.com>
Authored: Tue Aug 12 15:35:03 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Tue Aug 12 15:35:22 2014 +0800
----------------------------------------------------------------------
.../apache/camel/component/bean/MethodInfo.java | 6 ++
.../cxf/jaxrs/CxfRsConsumerWithBeanTest.java | 70 ++++++++++++++++++++
.../jaxrs/testbean/CustomerServiceResource.java | 11 +++
.../cxf/jaxrs/testbean/ServiceUtil.java | 24 +++++++
4 files changed, 111 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/ab8d8102/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
index 25d6b02..9236cd0 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
@@ -431,6 +431,12 @@ public class MethodInfo {
boolean multiParameterArray = false;
if (exchange.getIn().getHeader(Exchange.BEAN_MULTI_PARAMETER_ARRAY) != null) {
multiParameterArray = exchange.getIn().getHeader(Exchange.BEAN_MULTI_PARAMETER_ARRAY, Boolean.class);
+ if (multiParameterArray) {
+ // Just change the message body to an Object array
+ if (!(body instanceof Object[])) {
+ body = exchange.getIn().getBody(Object[].class);
+ }
+ }
}
// if there was an explicit method name to invoke, then we should support using
http://git-wip-us.apache.org/repos/asf/camel/blob/ab8d8102/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java
new file mode 100644
index 0000000..8d98975
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java
@@ -0,0 +1,70 @@
+/**
+ * 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.cxf.jaxrs;
+
+import javax.naming.Context;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.cxf.CXFTestSupport;
+import org.apache.camel.component.cxf.jaxrs.testbean.ServiceUtil;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
+import org.junit.Test;
+
+public class CxfRsConsumerWithBeanTest extends CamelTestSupport {
+ private static final String CXT = CXFTestSupport.getPort1() + "/CxfRsConsumerWithBeanTest";
+ private static final String CXF_RS_ENDPOINT_URI = "cxfrs://http://localhost:" + CXT + "/rest?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerServiceResource";
+
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("service", new ServiceUtil());
+ return context;
+ }
+
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from(CXF_RS_ENDPOINT_URI).to("bean://service?multiParameterArray=true");
+ };
+ };
+ }
+
+ @Test
+ public void testPutConsumer() throws Exception {
+
+ HttpPut put = new HttpPut("http://localhost:" + CXT + "/rest/customerservice/c20");
+ StringEntity entity = new StringEntity("string");
+ entity.setContentType("text/plain");
+ put.setEntity(entity);
+ CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+
+ try {
+ HttpResponse response = httpclient.execute(put);
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ assertEquals("c20string", EntityUtils.toString(response.getEntity()));
+ } finally {
+ httpclient.close();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/ab8d8102/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java
index c2e216f..4c69965 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java
@@ -16,10 +16,12 @@
*/
package org.apache.camel.component.cxf.jaxrs.testbean;
+import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
@@ -34,5 +36,14 @@ public interface CustomerServiceResource {
@PUT
@Path("/customers/")
Response updateCustomer(Customer customer);
+
+ @Path("/{id}")
+ @PUT()
+ @Consumes({ "application/xml", "text/plain",
+ "application/json" })
+ @Produces({ "application/xml", "text/plain",
+ "application/json" })
+ Object invoke(@PathParam("id") String id,
+ String payload);
}
// END SNIPPET: example
http://git-wip-us.apache.org/repos/asf/camel/blob/ab8d8102/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/ServiceUtil.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/ServiceUtil.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/ServiceUtil.java
new file mode 100644
index 0000000..22398e6
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/ServiceUtil.java
@@ -0,0 +1,24 @@
+/**
+ * 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.cxf.jaxrs.testbean;
+
+public class ServiceUtil {
+ public String invoke(String id, String payload) {
+ return id + payload;
+ }
+
+}
[2/3] git commit: Fixed the Karaf tool validating issue after upgrade
to karaf 2.3.6
Posted by ni...@apache.org.
Fixed the Karaf tool validating issue after upgrade to karaf 2.3.6
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e9a20c19
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e9a20c19
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e9a20c19
Branch: refs/heads/master
Commit: e9a20c19cc46e1960702ec5e25b8b05cbf2ab96c
Parents: fe35d1b
Author: Willem Jiang <wi...@gmail.com>
Authored: Tue Aug 12 15:33:48 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Tue Aug 12 15:35:22 2014 +0800
----------------------------------------------------------------------
platforms/karaf/features/pom.xml | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/e9a20c19/platforms/karaf/features/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/pom.xml b/platforms/karaf/features/pom.xml
index 6b55778..95b708f 100644
--- a/platforms/karaf/features/pom.xml
+++ b/platforms/karaf/features/pom.xml
@@ -140,7 +140,7 @@
</repository>
</repositories>
</profile>
-
+
<profile>
<id>validate</id>
<!-- Added the repository for the google script -->
@@ -163,6 +163,13 @@
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>features-maven-plugin</artifactId>
<version>${karaf-version}</version>
+ <dependencies>
+ <dependency>
+ <groupId>biz.aQute</groupId>
+ <artifactId>bndlib</artifactId>
+ <version>1.50.0</version>
+ </dependency>
+ </dependencies>
<configuration>
<file>${project.build.directory}/classes/${features.file}</file>
<karafConfig>${project.build.directory}/classes/config.properties</karafConfig>
[3/3] git commit: CAMEL-7682 Added multiParameterArray option to bean
DSL
Posted by ni...@apache.org.
CAMEL-7682 Added multiParameterArray option to bean DSL
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/759a4d62
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/759a4d62
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/759a4d62
Branch: refs/heads/master
Commit: 759a4d62bf6bc95bc240f075813541235e918305
Parents: ab8d810
Author: Willem Jiang <wi...@gmail.com>
Authored: Tue Aug 12 16:00:58 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Tue Aug 12 16:00:58 2014 +0800
----------------------------------------------------------------------
.../org/apache/camel/model/BeanDefinition.java | 15 +++++
.../apache/camel/model/ProcessorDefinition.java | 65 +++++++++++++++++++-
.../cxf/jaxrs/CxfRsConsumerWithBeanTest.java | 12 +++-
3 files changed, 87 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/759a4d62/camel-core/src/main/java/org/apache/camel/model/BeanDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/BeanDefinition.java b/camel-core/src/main/java/org/apache/camel/model/BeanDefinition.java
index 0211bbc..182f661 100644
--- a/camel-core/src/main/java/org/apache/camel/model/BeanDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/BeanDefinition.java
@@ -50,6 +50,8 @@ public class BeanDefinition extends NoOutputDefinition<BeanDefinition> {
private String beanType;
@XmlAttribute
private Boolean cache;
+ @XmlAttribute
+ private Boolean multiParameterArray;
@XmlTransient
private Class<?> beanClass;
@XmlTransient
@@ -139,6 +141,14 @@ public class BeanDefinition extends NoOutputDefinition<BeanDefinition> {
public void setCache(Boolean cache) {
this.cache = cache;
}
+
+ public Boolean getMultiParameterArray() {
+ return multiParameterArray;
+ }
+
+ public void setMultiParameterArray(Boolean multiParameterArray) {
+ this.multiParameterArray = multiParameterArray;
+ }
// Fluent API
//-------------------------------------------------------------------------
@@ -257,6 +267,11 @@ public class BeanDefinition extends NoOutputDefinition<BeanDefinition> {
beanHolder = bean != null ? new ConstantBeanHolder(bean, routeContext.getCamelContext()) : new ConstantTypeBeanHolder(clazz, routeContext.getCamelContext());
answer = new BeanProcessor(beanHolder);
}
+
+ // check for multiParameterArray setting
+ if (multiParameterArray != null) {
+ answer.setMultiParameterArray(multiParameterArray);
+ }
// check for method exists
if (method != null) {
http://git-wip-us.apache.org/repos/asf/camel/blob/759a4d62/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 0f98218..a704e05 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
@@ -2569,6 +2569,26 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
addOutput(answer);
return (Type) this;
}
+
+ /**
+ * <a href="http://camel.apache.org/message-translator.html">Message Translator EIP:</a>
+ * Adds a bean which is invoked which could be a final destination, or could be a transformation in a pipeline
+ *
+ * @param bean the bean to invoke
+ * @param method the method name to invoke on the bean (can be used to avoid ambiguity)
+ * @param multiparameterArray if it is ture, camel will treat the message body as an object array which holds
+ * the multi parameter
+ * @return the builder
+ */
+ @SuppressWarnings("unchecked")
+ public Type bean(Object bean, String method, boolean multiParameterArray) {
+ BeanDefinition answer = new BeanDefinition();
+ answer.setBean(bean);
+ answer.setMethod(method);
+ answer.setMultiParameterArray(multiParameterArray);
+ addOutput(answer);
+ return (Type) this;
+ }
/**
* <a href="http://camel.apache.org/message-translator.html">Message Translator EIP:</a>
@@ -2601,6 +2621,26 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
addOutput(answer);
return (Type) this;
}
+
+ /**
+ * <a href="http://camel.apache.org/message-translator.html">Message Translator EIP:</a>
+ * Adds a bean which is invoked which could be a final destination, or could be a transformation in a pipeline
+ *
+ * @param beanType the bean class, Camel will instantiate an object at runtime
+ * @param method the method name to invoke on the bean (can be used to avoid ambiguity)
+ * @param multiparameterArray if it is ture, camel will treat the message body as an object array which holds
+ * the multi parameter
+ * @return the builder
+ */
+ @SuppressWarnings("unchecked")
+ public Type bean(Class<?> beanType, String method, boolean multiParameterArray) {
+ BeanDefinition answer = new BeanDefinition();
+ answer.setBeanType(beanType);
+ answer.setMethod(method);
+ answer.setMultiParameterArray(multiParameterArray);
+ addOutput(answer);
+ return (Type) this;
+ }
/**
* <a href="http://camel.apache.org/message-translator.html">Message Translator EIP:</a>
@@ -2615,7 +2655,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
addOutput(answer);
return (Type) this;
}
-
+
/**
* <a href="http://camel.apache.org/message-translator.html">Message Translator EIP:</a>
* Adds a bean which is invoked which could be a final destination, or could be a transformation in a pipeline
@@ -2647,7 +2687,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
addOutput(answer);
return (Type) this;
}
-
+
/**
* <a href="http://camel.apache.org/message-translator.html">Message Translator EIP:</a>
* Adds a bean which is invoked which could be a final destination, or could be a transformation in a pipeline
@@ -2668,6 +2708,27 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
/**
* <a href="http://camel.apache.org/message-translator.html">Message Translator EIP:</a>
+ * Adds a bean which is invoked which could be a final destination, or could be a transformation in a pipeline
+ *
+ * @param ref reference to a bean to lookup in the registry
+ * @param method the method name to invoke on the bean (can be used to avoid ambiguity)
+ * @param cache if enabled, Camel will cache the result of the first Registry look-up.
+ * Cache can be enabled if the bean in the Registry is defined as a singleton scope.
+ * @param multiparameterArray if it is ture, camel will treat the message body as an object array which holds
+ * the multi parameter
+ * @return the builder
+ */
+ @SuppressWarnings("unchecked")
+ public Type beanRef(String ref, String method, boolean cache, boolean multiParameterArray) {
+ BeanDefinition answer = new BeanDefinition(ref, method);
+ answer.setCache(cache);
+ answer.setMultiParameterArray(multiParameterArray);
+ addOutput(answer);
+ return (Type) this;
+ }
+
+ /**
+ * <a href="http://camel.apache.org/message-translator.html">Message Translator EIP:</a>
* Adds a processor which sets the body on the IN message
*
* @return a expression builder clause to set the body
http://git-wip-us.apache.org/repos/asf/camel/blob/759a4d62/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java
index 8d98975..70706fe 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java
@@ -33,7 +33,8 @@ import org.junit.Test;
public class CxfRsConsumerWithBeanTest extends CamelTestSupport {
private static final String CXT = CXFTestSupport.getPort1() + "/CxfRsConsumerWithBeanTest";
private static final String CXF_RS_ENDPOINT_URI = "cxfrs://http://localhost:" + CXT + "/rest?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerServiceResource";
-
+ private static final String CXF_RS_ENDPOINT_URI_2 = "cxfrs://http://localhost:" + CXT + "/rest2?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerServiceResource";
+
@Override
protected Context createJndiContext() throws Exception {
Context context = super.createJndiContext();
@@ -46,14 +47,19 @@ public class CxfRsConsumerWithBeanTest extends CamelTestSupport {
return new RouteBuilder() {
public void configure() {
from(CXF_RS_ENDPOINT_URI).to("bean://service?multiParameterArray=true");
+ from(CXF_RS_ENDPOINT_URI_2).bean(ServiceUtil.class, "invoke", true);
};
};
}
@Test
public void testPutConsumer() throws Exception {
-
- HttpPut put = new HttpPut("http://localhost:" + CXT + "/rest/customerservice/c20");
+ sendPutRequest("http://localhost:" + CXT + "/rest/customerservice/c20");
+ sendPutRequest("http://localhost:" + CXT + "/rest2/customerservice/c20");
+ }
+
+ private void sendPutRequest(String uri) throws Exception {
+ HttpPut put = new HttpPut(uri);
StringEntity entity = new StringEntity("string");
entity.setContentType("text/plain");
put.setEntity(entity);